diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsproxywidget.cpp | 31 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsproxywidget_p.h | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qtooltip.cpp | 4 |
4 files changed, 41 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 2132526..bdd41cd 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -897,6 +897,29 @@ bool QGraphicsProxyWidget::event(QEvent *event) } break; } +#ifndef QT_NO_TOOLTIP + case QEvent::GraphicsSceneHelp: { + // Propagate the help event (for tooltip) to the widget under mouse + if (d->lastWidgetUnderMouse) { + QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event); + QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint(); + QHelpEvent e(QEvent::ToolTip, pos, he->screenPos()); + QApplication::sendEvent(d->lastWidgetUnderMouse, &e); + event->setAccepted(e.isAccepted()); + return e.isAccepted(); + } + break; + } + case QEvent::ToolTipChange: { + // Propagate tooltip change to the widget + if (!d->tooltipChangeMode) { + d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode; + d->widget->setToolTip(toolTip()); + d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode; + } + break; + } +#endif default: break; } @@ -952,6 +975,14 @@ bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event) d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode; } break; + case QEvent::ToolTipChange: + // Propagate tooltip change to the proxy. + if (!d->tooltipChangeMode) { + d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode; + setToolTip(d->widget->toolTip()); + d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode; + } + break; default: break; } diff --git a/src/gui/graphicsview/qgraphicsproxywidget_p.h b/src/gui/graphicsview/qgraphicsproxywidget_p.h index 8aed363..0e29a7e 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget_p.h +++ b/src/gui/graphicsview/qgraphicsproxywidget_p.h @@ -72,6 +72,7 @@ public: enabledChangeMode(NoMode), styleChangeMode(NoMode), paletteChangeMode(NoMode), + tooltipChangeMode(NoMode), focusFromWidgetToProxy(0) { } void init(); @@ -117,6 +118,7 @@ public: quint32 enabledChangeMode : 2; quint32 styleChangeMode : 2; quint32 paletteChangeMode : 2; + quint32 tooltipChangeMode : 2; quint32 focusFromWidgetToProxy : 1; quint32 proxyIsGivingFocus : 1; }; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 6581727..b368a82 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -3772,6 +3772,12 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) QGraphicsItem *toolTipItem = 0; for (int i = 0; i < itemsAtPos.size(); ++i) { QGraphicsItem *tmp = itemsAtPos.at(i); + if (tmp->d_func()->isProxyWidget()) { + // if the item is a proxy widget, the event is forwarded to it + sendEvent(tmp, helpEvent); + if (helpEvent->isAccepted()) + return; + } if (!tmp->toolTip().isEmpty()) { toolTipItem = tmp; break; diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp index 1343959..c8fcf45 100644 --- a/src/gui/kernel/qtooltip.cpp +++ b/src/gui/kernel/qtooltip.cpp @@ -168,9 +168,9 @@ QTipLabel *QTipLabel::instance = 0; QTipLabel::QTipLabel(const QString &text, QWidget *w) #ifndef QT_NO_STYLE_STYLESHEET - : QLabel(w, Qt::ToolTip), styleSheetParent(0), widget(0) + : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(0), widget(0) #else - : QLabel(w, Qt::ToolTip), widget(0) + : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), widget(0) #endif { delete instance; |