Results 1 to 5 of 5

Thread: Connecting QwtPlotCurve and QTableView (NOOB)

  1. #1
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Connecting QwtPlotCurve and QTableView (NOOB)

    hello all,

    What would be the best way to connect a QTableView and a QwtPlotCurve, in a way that I will need to keep the data only once?
    I want to show the table and the curve, and connect them (data edited in the table will be reflected in the graph, selection in either will be reflected on the second).

    I know it has something to do with subclassing QwtData, but as I'm new to all this, I didn't manage it on my own yet.

    Any advice? (if anyone knows of an example it will be great!)

    Thanks,
    Yuvalal

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Connecting QwtPlotCurve and QTableView (NOOB)

    I don't think you want to connect the QTableView to the plot; you want to connect the model to the plot. If you derive from QwtData and use that class to monitor your model's dataChanged() or modelReset() signals, then these will tell you when the plot needs to be updated. The data will still only live in one place (the model).

    I don't have an example (yet), but I am planning to do exactly this at some point later when I revise my application to use Model/View instead of hard-coded data structures and table widgets. Once I do that, then QwtPlots will just become another view of the model. QwtData will be the "glue" that ties them together.

  3. The following user says thank you to d_stranz for this useful post:

    yuvalal (7th March 2011)

  4. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Connecting QwtPlotCurve and QTableView (NOOB)

    Quote Originally Posted by d_stranz View Post
    I don't have an example (yet), but I am planning to do exactly this at some point later when I revise my application to use Model/View instead of hard-coded data structures and table widgets. Once I do that, then QwtPlots will just become another view of the model. QwtData will be the "glue" that ties them together.
    Qt models might be a performance hog I wouldn't recommend to use for curves with many points.

    QAbstractModel is made for almost any type of data structure - not only for simple arrays - with the price of several levels of indirections. Consider that these need to be resolved for every point ( in Qwt 5 for every coordinate ) for drawing a curve line + the same for the symbols !

    That's the main reason why I don't use QAbstractModel in Qwt and why I believe, that other chart packages made some wrong decisions.

    You can compare QAbstractModel with QwtData - both are bridges between the application and the real data structures. I recommend to implement both independently - not stacking them.

    Uwe

  5. The following user says thank you to Uwe for this useful post:

    yuvalal (7th March 2011)

  6. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Connecting QwtPlotCurve and QTableView (NOOB)

    Qt models might be a performance hog I wouldn't recommend to use for curves with many points.
    Yes, I would agree that this could be the case. It might also happen that even with a proxy model, the proxy's filterAcceptsColumn() and filterAcceptsRow() methods get called for every row and column in the base model and this could cause some performance drain as well if the model has many rows (e.g. points).

    My primary thoughts about implementing in this way was to give a user-friendly way to display the data in a table using QwtPlot. I have nearly finished porting a spreadsheet engine from C# into generic (non-Qt) C++ (google "CoreCalc"), and am now wrapping a QAbstractTableModel / QTableView around it so I can have an embeddable spreadsheet for my apps. Data reduction calculations done in the app will be filled into the spreadsheet as non-editable cells; users can then use spreadsheet functions to combine cells into new derived results. (For example, the user wants to scale a data reduction result column from linear to log).

    Using a QSortFilterProxyModel between the base model and the plot also permits the user to sort results that may not be sorted in the base model to be able to view trends, etc.

    My plots are not usually dynamic; once the spreadsheet is filled or recalculated, the plots will be automatically updated and then the user will play with the plots themselves. So in my case I don't think that the combination of QwtData and QAbstractTableModel will be too much of a performance drag.

    I guess I will find out.
    Last edited by d_stranz; 6th March 2011 at 23:57.

  7. #5
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Connecting QwtPlotCurve and QTableView (NOOB)

    Thanks a lot for the replies and discussion.
    I believe I'll try both options, and report back on what I find (or will ask more specific questions..)
    Yuvalal

Similar Threads

  1. How to get Text value of a QDomElement ? (noob question)
    By BillGates in forum Qt Programming
    Replies: 6
    Last Post: 31st August 2010, 14:01
  2. QWizard noob question
    By Ossi in forum Newbie
    Replies: 5
    Last Post: 2nd September 2009, 12:30
  3. a simple noob question
    By wrproject in forum Newbie
    Replies: 1
    Last Post: 1st July 2008, 23:25
  4. noob prob?
    By triperzz in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2008, 10:19
  5. [Qt4] Noob and custom Item Delegate
    By naresh in forum Newbie
    Replies: 36
    Last Post: 19th March 2006, 15:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.