QListView: Add tooltips to each entry
-
I want to have each entry of a QListView its own tooltip.
I found some quit old examples in the wild that using the mouse cursors actual position determining the item under it and creating their own QToolTip instance.I don't want to hack like this and hope that today in Qt6 there is an easier solution via just adding a tooltip string to an item object. But I couldn't find something like this.
Any ideas?
-
I want to have each entry of a QListView its own tooltip.
I found some quit old examples in the wild that using the mouse cursors actual position determining the item under it and creating their own QToolTip instance.I don't want to hack like this and hope that today in Qt6 there is an easier solution via just adding a tooltip string to an item object. But I couldn't find something like this.
Any ideas?
@buhtz said in QListView: Add tooltips to each entry:
I want to have each entry of a QListView its own tooltip.
So what's wrong with QListWidgetItem::setToolTip()?/edit: I misread it as QListWidget
-
Hi,
What about using the Qt::TooltipRole in your model ?
-
I want to have each entry of a QListView its own tooltip.
I found some quit old examples in the wild that using the mouse cursors actual position determining the item under it and creating their own QToolTip instance.I don't want to hack like this and hope that today in Qt6 there is an easier solution via just adding a tooltip string to an item object. But I couldn't find something like this.
Any ideas?
Further to @SGaist's suggestion: if you do not want those tool tips in every view using the model, or you have no control over the original model, you may be able to use a QIdentityProxyModel sub-class to inject tooltips into the Qt::TooltipRole.
-
Wow a lot of oportunities.
Thanks a lot. I will check this out.Sorry, I was really locking into the docs but wasn't able to find the related constructs. On the other hand I have to explain, to my defense, I have not constructed that specific ListView myself. It is code I took over.