diff --git a/include/wx/qt/private/treeitemdelegate.h b/include/wx/qt/private/treeitemdelegate.h index 65025de442..632172f6ec 100644 --- a/include/wx/qt/private/treeitemdelegate.h +++ b/include/wx/qt/private/treeitemdelegate.h @@ -11,6 +11,7 @@ #define _WX_QT_PRIVATE_TREEITEM_DELEGATE_H #include +#include #include "wx/app.h" #include "wx/textctrl.h" @@ -67,6 +68,28 @@ public: QStyledItemDelegate::setModelData(editor, model, index); } + bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) + { + if ( event->type() == QEvent::ToolTip ) + { + const QRect &itemRect = view->visualRect(index); + const QSize &bestSize = sizeHint(option, index); + if ( itemRect.width() < bestSize.width() ) + { + const QString &value = index.data(Qt::DisplayRole).toString(); + QToolTip::showText(event->globalPos(), value, view); + } + else + { + QToolTip::hideText(); + } + + return true; + } + + return QStyledItemDelegate::helpEvent(event, view, option, index); + } + private: wxWindow* m_parent; mutable wxTextCtrl* m_textCtrl;