PDA

View Full Version : How to set the tooltip of a qtreeview items on mouse over.



RJ
23rd August 2012, 07:55
Hi all,

I have a Qtreeview and I want to set the tooltip on mouse over. I am able to set the tooltip for each item. Now I have two concerns
1. I want to display the tooltip only for those items whose text is truncated.
2. I want to display the tooltip on the mouseover.

currently tooltip of that item is being shown which one is selected doesn't matter which item mouse pointer is on.

Thanks for your help in advance :)

spirit
23rd August 2012, 10:47
See Qt::ToolTipRole (http://qt-project.org/doc/qt-4.8/qt.html#ItemDataRole-enum).

RJ
23rd August 2012, 12:40
See at Qt::ToolTipRole (http://qt-project.org/doc/qt-4.8/qt.html#ItemDataRole-enum).

thanks for reply...
here is wat i am doing..

ui->mytreeView->setToolTip(index.model()->data(index,Qt::DisplayRole).toString());

i want to set the tooltip only for the text which are going beyond the column width.
how to do that..I can have the column width here but how can I get the text width here?

thomas@itest
23rd August 2012, 15:06
hi !

ui->mytreeView->setToolTip() ... you're setting a tooltip for the whole treeview ...

If you want to get helped, you need to tell us more about the model/view subclasses you're using !

anyway, look at your model instead than your view to set a specific tooltip for each item