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.
Re: toggle visibility of QList<QTreeWidgetItem*>
Re: toggle visibility of QList<QTreeWidgetItem*>
QTreeWidget::findItems()
Cheers,
_
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:
Code:
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:
Code:
for(int j = 0; j < mSortItems.count(); j ++)
{
tree->setItemHidden( mSortItems[j], false );
}
This solved the problem..thanks! :-)
Re: toggle visibility of QList<QTreeWidgetItem*>
You can also call setHidden(bool) on the items themselves.
Cheers,
_