How to Get The QTreeWidgetItem from QTreeWidget using a QWidget
-
Hi,
I have a QTreeWidget object which has lots of QTreeWidgetItem's and some of these items have a QWidget. Now I have an QWidget object I want to get the corresponding QTreeWidgetItem that has the same QWidget without iterating through all the items in QTreeWidget?
-
Hi,
I have a QTreeWidget object which has lots of QTreeWidgetItem's and some of these items have a QWidget. Now I have an QWidget object I want to get the corresponding QTreeWidgetItem that has the same QWidget without iterating through all the items in QTreeWidget?
@AbhiVarma said in How to Get The QTreeWidgetItem from QTreeWidget using a QWidget:
and some of these items have a QWidget
And how does that happen? Do you perchance use
QTreeWidget::setItemWidget()?QTreeWidgetItem that has the same QWidget without iterating through all the items in QTreeWidget?
You are basically out of luck. I would expect to have to iterate.
setItemWidget()does not put anything into the widget so that its item/column can be retrieved. If it's really important to have fast lookup/back mapping, you might add this information to your widget(s) e.g. viaQObject::setProperty(). I don't know how easy this might be to use if you adding/removing/moving yourQTreeWidgetItems.