Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QToolButton not receiving ToolTip events
Forum Updated to NodeBB v4.3 + New Features

QToolButton not receiving ToolTip events

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ghutchis
    wrote on last edited by
    #1

    Somehow widgets aren't getting tool tip events.

    I've used setToolTip(...) on QAction that go into a QToolBar (although IIRC the default would set the tooltip to the action text).

    The tool tips never show up.

    I checked a few things with an event filter - the QToolBar and the QToolButton never seem to receive QEvent::ToolTip events.

    I can copy action->toolTip() to action->setStatusTip( action->toolTip() ) and they show up as status tips.

    I do see QEvent::Enter and QEvent::HoverMove events.. so I could, in principal use those to fire off tool tips. But I'd like to understand why I'm not getting QEvent::ToolTip on my widgets.

    Any ideas? Any place to start debugging?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      What does action->associatedWidgets() return? QActions aren't widgets themselves but this will tell you what widget(s) the action is associated with.

      G 1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Can you provide a minimal compilable example that shows that behaviour ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M mchinand

          What does action->associatedWidgets() return? QActions aren't widgets themselves but this will tell you what widget(s) the action is associated with.

          G Offline
          G Offline
          ghutchis
          wrote on last edited by
          #4

          @mchinand said in QToolButton not receiving ToolTip events:

          action->associatedWidgets()

          The actions are giving:

           action:  "Player" QToolBar
           action:  "Player" QToolButton
          

          Should they also have an associated widget of the MainWindow?

          @SGaist said in QToolButton not receiving ToolTip events:

          Can you provide a minimal compilable example that shows that behaviour ?

          I wish. Likely if I had a minimal example, I'd have figured out the problem, sorry.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Then I would recommend making one to help you find the issue.

            We do not have enough information to guess what is going on.

            You may have an event filter somewhere or maybe some strange interaction with a style you are using etc.

            The other way is to make your application barebones and only keep the code related directly to the tooltips to see if it's working and if so, gradually add back the rest until it fails.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            G 1 Reply Last reply
            1
            • SGaistS SGaist

              Then I would recommend making one to help you find the issue.

              We do not have enough information to guess what is going on.

              You may have an event filter somewhere or maybe some strange interaction with a style you are using etc.

              The other way is to make your application barebones and only keep the code related directly to the tooltips to see if it's working and if so, gradually add back the rest until it fails.

              G Offline
              G Offline
              ghutchis
              wrote on last edited by
              #6

              @SGaist said in QToolButton not receiving ToolTip events:

              You may have an event filter somewhere or maybe some strange interaction with a style you are using etc.

              Just to be clear, those would be the most likely issues to prevent a ToolTip event, yes?

              Thanks.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                ghutchis
                wrote on last edited by
                #7

                For now, I'm just fudging it - I installed an event filter for QEvent::Enter:

                Not great, but it works:

                 if (event->type() == QEvent::Enter) {
                    QWidget* target = qobject_cast<QWidget*>(object);
                    QEnterEvent* ee = dynamic_cast<QEnterEvent*>(event);
                    if (target && ee) {
                      QToolTip::showText(ee->globalPos(), target->toolTip(), target);
                      return true;
                    }
                  }
                
                  return false;
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved