Tooltips & Qt4 tree views
Hi
I've looked everywhere in the documentation but not found any hint about setting tooltips for QTreeView in an intelliigent way (like Qt3's QListView i.e. tooltips are displayed when item are not shown at once).
How can i do that in Qt4?
Thanks in advance
Re: Tooltips & Qt4 tree views
Make your model return the tooltip text of each of the items for the Qt::ToolTipRole role.
Re: Tooltips & Qt4 tree views
Quote:
Originally Posted by wysota
Make your model return the tooltip text of each of the items for the Qt::ToolTipRole role.
I know that. But then the tooltips are always shown not when the contents are not shown entirely.
Am i clear?
Re: Tooltips & Qt4 tree views
I don't quite understand. Can you provide an example or somewhat broader explanation?
If I understand, you want to show the tooltip only if a column is too narrow for the whole text of the item to fit in it?
Re: Tooltips & Qt4 tree views
If you want to change the way the view displays the tooltip, you'll have to handle QAbstractItemView::viewportEvent().
Re: Tooltips & Qt4 tree views
Quote:
Originally Posted by wysota
If I understand, you want to show the tooltip only if a column is too narrow for the whole text of the item to fit in it?
Yes. This is what i want and Qt3's QListView does that by default.
Quote:
Originally Posted by wysota
If you want to change the way the view displays the tooltip, you'll have to handle QAbstractItemView::viewportEvent().
I think this should be the default behaviour. What do you say?
Thanks for your patience
Re: Tooltips & Qt4 tree views
Quote:
Originally Posted by yogeshm02
I think this should be the default behaviour. What do you say?
No, this shouldn't be a default behaviour. Why? If an item has a tooltip, it is the tooltip that is displayed and not the item name. It sounds very sane to me.
Re: Tooltips & Qt4 tree views
Quote:
Originally Posted by wysota
No, this shouldn't be a default behaviour. Why? If an item has a tooltip, it is the tooltip that is displayed and not the item name. It sounds very sane to me.
Agreed with above. But i wanted that behaviour if no tooltip was specified. I'll inherit from QTreeView and see if i can do what i want and if i am successful then i will post here. Bye till then.
Thanks