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. How to display toolTip when mouse on "folded" QComboBox
QtWS25 Last Chance

How to display toolTip when mouse on "folded" QComboBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 5.7k Views
  • 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.
  • P Offline
    P Offline
    PALYGAP
    wrote on last edited by
    #1

    I have a QComboBox (in QDialog) that is not large enough to display the full text of an item when it is "folded". I want to display a tooTip with the full current item text when the mouse is positioned over the QComboBox. In Qt Creator, I tried setting the toolTip property with a constant (just to try) and set mouseTracking on but that does not work. Any idea how to get that done ?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      You can subclass the combo and catch event

      bool yourcb::event(QEvent* event) {
      if (event->type() == QEvent::ToolTip) {
      QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event);
      QPoint mpos = helpEvent->pos(); // might need mapToGlobal. see doc. i thinks its already translated.
      QToolTip::showText( mpos , "Pop My B. up" );

      Alternative you could use event filter
      http://stackoverflow.com/questions/411823/how-do-i-implement-qhoverevent-in-qt
      To catch hover and then QToolTip::showText

      Disclaimer. Not tried on a combobox. Only custom widget :)

      1 Reply Last reply
      2
      • P Offline
        P Offline
        PALYGAP
        wrote on last edited by
        #3

        Hi,

        Thanks for the ideas. I'll give it a try this WE. I'll first have to read about Event Filters which I have not tried up to now.

        I was thinking that this toolTip would be sort of "integrated" in Qt Creator since there are parameters for it in the Creator's IHM.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It is integrated and for most widgets, you just set the tooltip text and
          it will be happy.

          But as Far as I know, a closed combobox wont display tool tips pr default ,
          the way you want it.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PALYGAP
            wrote on last edited by PALYGAP
            #5

            OK. Make sense to not have tooltip on closed QCOMBOBOX by "default".

            mrjjM 1 Reply Last reply
            0
            • P PALYGAP

              OK. Make sense to not have tooltip on closed QCOMBOBOX by "default".

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @PALYGAP
              Yeah, not tested when it uses its tooltip but
              i dont think it was in close state even would be smart.
              (you tested that too)

              If you have time, i suggest trying with eventfilter as such filter is also functional for many other things
              so its good pratice.

              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