[ENDED]set tooltip on an icon
-
Hello,
I'm currently working on a QTableWidget.
Some of the QTableWidgetItems have an icon ( with the function setICon ) that indicate the type of item.(some items represent a desk, some other chairs... etc)
The icon could be not obvious enough for some users so I would like to set a tooltip on it that also say what type it is. (for example display "chair" as tooltip ont the icon of the chair)
I can't find a way to do it.
I also don't want to set the tooltip to the entire item, just on the icon.Thanks
-
Does "QTableWidgetItem::setToolTip() ":http://doc.qt.nokia.com/4.7/qtablewidgetitem.html#setToolTip do the trick?
-
I over-read that, sorry. And I'm sorry again - there is no builtin solution for your problem, the tooltip is for the whole item.
To achieve this, I would switch from the QTableWidget to QTableView, create a model, add a custom role to that one (IconToolTipRole). One would probably have to subclass the table view and reimplement viewportEvent (see the implementation of "QAbstractItemView::viewportEvent() ":http://doc.qt.nokia.com/4.7/qabstractitemview.html#viewportEvent, it handles the tool tip request) to get the actual position of the mouse pointer.