Results 1 to 5 of 5

Thread: QTreeWidgetItemIterator howto

  1. #1
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeWidgetItemIterator howto

    I want to loop through the topmost items of a QTreeWidget. I guess this would be most convenient done with the new QTreeWidgetItemIterator class introduced with 4.1.

    Does anybody know where to find documentation or a sample how it works? Seems it is not yet in the Qt Assistant (at least in the 4.1 commercial)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidgetItemIterator howto

    And there is such an iterator? If it's not documented, then it's probably not for public use.

    Use this:
    Qt Code:
    1. int ind=0;
    2. while(QTreeWidgetItem *item = treeWidget->topLevelItem(ind)){
    3. doSomething(item);
    4. ind++;
    5. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidgetItemIterator howto

    It's in the 4.1 changelog. I think you should report to the tasktracker as a bug.

  4. #4
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidgetItemIterator howto

    Thanks for the loop wysota, it works for my current need.

    I have asked TT to provide documentation/how-to for the new class.

  5. #5
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidgetItemIterator howto

    Attached you find the documentation from the snapshot along with a small example that I received from trolltech support.
    Attached Files Attached Files

  6. The following user says thank you to seneca for this useful post:

    jpn (10th March 2006)

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.