Results 1 to 5 of 5

Thread: toggle visibility of QList<QTreeWidgetItem*>

  1. #1
    Join Date
    Aug 2013
    Posts
    41
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default toggle visibility of QList<QTreeWidgetItem*>

    Hi,

    I have a list of QTreeWidgetItems as in QList<QTreeWidgetItem*> appended to the QList and added as 'addTopLevelItems' to the tree. I would like to hide/show certain items in the list by toggling them (through a checkbox).
    I know the "string" which needs to be toggled.

    How can I achieve this? Please suggest.

  2. #2
    Join Date
    Mar 2014
    Posts
    11
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: toggle visibility of QList<QTreeWidgetItem*>

    See here:
    http://qt-project.org/forums/viewthread/7045

    Sorry wrong side...

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: toggle visibility of QList<QTreeWidgetItem*>

    QTreeWidget::findItems()

    Cheers,
    _

  4. #4
    Join Date
    Aug 2013
    Posts
    41
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: toggle visibility of QList<QTreeWidgetItem*>

    Hi anda,

    I have a QTreeWidget containing 4 columns.


    I would like to toggle (hide/show) entire row based on the string at column 2. Therefore, as per your suggestion I tried the following:

    Qt Code:
    1. QList<QTreeWidgetItem*> mSortItems; // new QList to find items in a tree
    2. mSortItems = tree->findItems("Info", Qt::MatchExactly, 2); // tree is a pointer to QTreeWidget
    To copy to clipboard, switch view to plain text mode 

    It has found (lets say 3 items) in the that column. Now, how can I extract the index(row number) of those 3 items?

    Please help.


    Added after 1 37 minutes:


    Qt Code:
    1. for(int j = 0; j < mSortItems.count(); j ++)
    2. {
    3. tree->setItemHidden( mSortItems[j], false );
    4. }
    To copy to clipboard, switch view to plain text mode 

    This solved the problem..thanks! :-)
    Last edited by uz_qt; 7th March 2014 at 17:45.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: toggle visibility of QList<QTreeWidgetItem*>

    You can also call setHidden(bool) on the items themselves.

    Cheers,
    _

Similar Threads

  1. Alternative iteration over a QList<QTreeWidgetItem*>
    By Axtroz in forum Qt Programming
    Replies: 3
    Last Post: 24th June 2012, 00:00
  2. Toggle dialog visibility on application switch
    By gvanvoor in forum Qt Programming
    Replies: 12
    Last Post: 20th June 2012, 12:11
  3. Replies: 3
    Last Post: 26th September 2011, 09:20
  4. Replies: 4
    Last Post: 20th August 2010, 14:54
  5. QList and QTreeWidgetItem??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2006, 15:47

Tags for this Thread

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.