Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How to display toolTip when mouse on "folded" QComboBox

    General and Desktop
    2
    6
    4756
    Loading More Posts
    • 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
      PALYGAP last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        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 Reply Quote 2
        • P
          PALYGAP last edited by

          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 Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • P
              PALYGAP last edited by PALYGAP

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

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @PALYGAP last edited by

                @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 Reply Quote 0
                • First post
                  Last post