Custom Tooltip regions on QWidget

  • Is there a standardized way if I have a QWidget and would like to have several custom regions (defined by QRect), where hovering over each one triggers a different tooltip?

  • You should override the event() function and look for the QEvent::ToolTip event. When you get that one, cast the QEvent to a QHelpEvent and get the mouse position, match that to your areas and show the appropriate tool tip.

  • Moderators

    From the "documentation": for QToolTip...

    bq. It is also possible to show different tool tips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget's event() function and call QToolTip::showText() with the text you want to display. The Tooltips example illustrates this technique.

    EDIT: So, pretty much what Franzk said above...

  • Thanks for the (tool)tip.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.