How to set tooltip for only QIcon which is inside QTreeWidgetIteam?
-
In QTreeWidgetIteam have two different elements. QIcon and QLebel.
If we set the tool tip like below, then it will give the tooltip to the entire cell of QTreeWidgetIteam.pTreeWidgetItem->setToolTip(ColNum, "Tooltip Text");
I have to set the tooltip only on the Icon inside QTreeWidgetIteam.
How to achieve this?Let me know If there is any query on this question.
-
In QTreeWidgetIteam have two different elements. QIcon and QLebel.
If we set the tool tip like below, then it will give the tooltip to the entire cell of QTreeWidgetIteam.pTreeWidgetItem->setToolTip(ColNum, "Tooltip Text");
I have to set the tooltip only on the Icon inside QTreeWidgetIteam.
How to achieve this?Let me know If there is any query on this question.
@bhvn
Hello and welcome.I think this will be tricky, no easy way to do it. I can only see overriding the whole
QTreeWidget
'sevent(QEvent *event)
and doing your own calculations for the mouse position to decide whether to show or ignore. See https://doc.qt.io/qt-6/qtwidgets-widgets-tooltips-example.html for inspiration. But I don't think you can even discover the icon's position.Meanwhile, I do not understand
In QTreeWidgetIteam have two different elements. QIcon and QLebel.
QTreeWidgetItem
s do not have widgets likeQIcon
orQLabel
, maybe you are using QTreeWidget::setItemWidget(). You do not explain. But in such a case can't you set the tooltip on whatever widget you are placing there if you only want it to apply to that widget? -
@bhvn
Hello and welcome.I think this will be tricky, no easy way to do it. I can only see overriding the whole
QTreeWidget
'sevent(QEvent *event)
and doing your own calculations for the mouse position to decide whether to show or ignore. See https://doc.qt.io/qt-6/qtwidgets-widgets-tooltips-example.html for inspiration. But I don't think you can even discover the icon's position.Meanwhile, I do not understand
In QTreeWidgetIteam have two different elements. QIcon and QLebel.
QTreeWidgetItem
s do not have widgets likeQIcon
orQLabel
, maybe you are using QTreeWidget::setItemWidget(). You do not explain. But in such a case can't you set the tooltip on whatever widget you are placing there if you only want it to apply to that widget?