Results 1 to 3 of 3

Thread: Best Way for a dynamic Widget or adapting QListView, QListWidget?

  1. #1
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Best Way for a dynamic Widget or adapting QListView, QListWidget?

    Hi Everyone,

    I want to Exclude several groups of Data. ( from a calculation...)
    And i'am thinking about what the best way it will be, how to do it. I principal i intend to do something like this:
    The range of the Wavelength to exclude should be selected in a QSpinBox: From and a QSpinBox To. and this should be stored somewhere.

    1) Way i can try to edit the QSpinboxes, and with an Enter, a set of new QSpinboxes will be shown dynamically at runtime. (Maybe with new MyWidget...) The From - To -Data will be stored in an ascii file. because i need them to be available the next time the SW starts up. (without the white QListView in the picture below...)
    Therefore i think i need to make my own Widget, as shown in the Picture.(actually in the pic there are several qt widgets..)
    My Question here is: Whats the best way to implement this dynamically, and do it with some sliders? e.g. if i have 10 items how can i navigate through them?

    2) Way I only have on pair of QSpinBoxes From To (already in the picture) and i try to get the Data in a QListView or QListWidget. Therefore i may have to subclass them to get my Data in there. like:

    Qt Code:
    1. class CMyItem
    2. { // Wavelength to be excluded from Calculation..
    3. public:
    4. // Inline definition
    5. CMyItem() { LowerLimit = 0.0; UpperLimit = 0.0; }
    6. double LowerLimit;
    7. double UpperLimit;
    8. };
    9.  
    10. class CMyListView : public QListView
    11. {
    12. public:
    13. CMyListView(QWidget *parent = 0);
    14. // ~CMyQListView();
    15.  
    16. CMyItem MyItem;
    17. };
    To copy to clipboard, switch view to plain text mode 

    But QListView has not something like addData() which i can trace. In the QListWidget class reference is a hint that:For a more flexible list view widget, use the QListView class with a standard model.

    3) Way Something complete other?

    I've tested both versions an didn't come far until now. And i'm asking what maybe will be more easier or elegant to try to implement? Or is there already something similar around in Qt?

    I'm a little stucked what the best way will be
    Many thanks for any suggestions
    Astronomy


  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Best Way for a dynamic Widget or adapting QListView, QListWidget?

    I understand your question as follows:

    You have some data records and each record has a "wavelength".
    You want to filter the records where the wavelength is between a certain range.
    You want to display those records that match the filter.

    Suggestion on how to implement this with Qt:

    Create some kind of listmodel, either subclassing or use one of the existing ones that only display the data.
    Implement the filtering using a QSortFilterProxyModel. Subclass QSortFilterProxyModel to match only rows that match you criteria: between upper and lower wavelength.

    Make a structure like this: YourList => YorFilterProxy => QListView.
    It's nice to be important but it's more important to be nice.

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

    Astronomy (18th February 2010)

  4. #3
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best Way for a dynamic Widget or adapting QListView, QListWidget?

    Hi Axel,
    Yes u got me.
    Thanks for the hints, especially QSortFilterProxyModel.
    Until now i have stored my Data to Exclude in two QComboBoxes(double) and they are connected via the Index (per max-min Range per Index..). This is working but it looks badly *gg*. I'll try your Suggestion out.

    Thanx
    Astronomy

Similar Threads

  1. add custom widget items to QListView or QListWidget
    By yazwas in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2010, 23:36
  2. [solved]QListView dynamic item height
    By kernel_panic in forum Qt Programming
    Replies: 8
    Last Post: 17th March 2009, 15:05
  3. QListWidget or QListView with QLabel(s)
    By lukass in forum Newbie
    Replies: 6
    Last Post: 11th August 2008, 10:48
  4. QListWidget::currentRowChanged() for QListView
    By Lykurg in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2007, 16:27
  5. QListWidget / QListView Bug ?
    By guilugi in forum Qt Programming
    Replies: 5
    Last Post: 16th November 2006, 12:33

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.