View Full Version : toggle visibility of QList<QTreeWidgetItem*>
uz_qt
7th March 2014, 11:43
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.
cecchinoSMI
7th March 2014, 11:51
See here:
http://qt-project.org/forums/viewthread/7045
Sorry wrong side...
anda_skoa
7th March 2014, 14:33
QTreeWidget::findItems()
Cheers,
_
uz_qt
7th March 2014, 16:45
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:
QList<QTreeWidgetItem*> mSortItems; // new QList to find items in a tree
mSortItems = tree->findItems("Info", Qt::MatchExactly, 2); // tree is a pointer to QTreeWidget
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:
for(int j = 0; j < mSortItems.count(); j ++)
{
tree->setItemHidden( mSortItems[j], false );
}
This solved the problem..thanks! :-)
anda_skoa
7th March 2014, 19:07
You can also call setHidden(bool) on the items themselves.
Cheers,
_
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.