Display item's tooltip if it has one

This commit is contained in:
Arnaud Bienner 2012-06-27 00:57:31 +02:00
parent f87bbb9057
commit 2fe212e68b
1 changed files with 8 additions and 2 deletions

View File

@ -135,9 +135,15 @@ bool LibraryItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view,
real_text = sizeHint(option, index);
displayed_text = view->visualRect(index);
is_elided = displayed_text.width() < real_text.width();
if(is_elided) {
if (is_elided) {
QToolTip::showText(he->globalPos(), text, view);
} else { // in case that another text was previously displayed
} else if (index.data(Qt::ToolTipRole).isValid()) {
// If the item has a tooltip text, display it
QString tooltip_text = index.data(Qt::ToolTipRole).toString();
QToolTip::showText(he->globalPos(), tooltip_text, view);
} else {
// in case that another text was previously displayed
QToolTip::hideText();
}
return true;