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 show tooltip for a widget from code
QtWS25 Last Chance

How to show tooltip for a widget from code

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 31.8k 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.
  • J Offline
    J Offline
    jarda
    wrote on 18 Oct 2011, 12:13 last edited by
    #1

    Hello all,
    I want to show tooltip for QLineEdit from a code as a hint for a user that there (in lineEdit) is something wrong.
    But I cannot find how to do it. I want to ask if it is possible to show tooltip by the code?

    Thank in advance,
    Jarda

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on 18 Oct 2011, 12:23 last edited by
      #2

      Try this:
      @QToolTip::showText( widget->mapToGlobal( QPoint( 0, 0 ) ), errorString );@

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jarda
        wrote on 18 Oct 2011, 12:32 last edited by
        #3

        Thanks very much p-himik. That is exactly what I needed.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Iktwo
          wrote on 19 Oct 2011, 04:57 last edited by
          #4

          I think that the correct way is using this:

          @setToolTip( const QString & )@

          like
          @QString tooltip="Wrong text near: .."
          lineEdt->setToolTip(tooltip)@

          1 Reply Last reply
          0
          • P Offline
            P Offline
            p-himik
            wrote on 19 Oct 2011, 05:29 last edited by
            #5

            This will show toolTip only if you hold your mouse cursor on this widget for a while. Jarda wants to show it on demand from his code.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              Iktwo
              wrote on 19 Oct 2011, 11:53 last edited by
              #6

              My bad, as the tittle say "how to show tooltip for a widget from code", but what jarda wants is to "trigger" the show tooltip..

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on 19 Oct 2011, 13:13 last edited by
                #7

                Trigger as in "show", yes. Your code does not trigger nor show, it only sets.

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  Iktwo
                  wrote on 19 Oct 2011, 13:15 last edited by
                  #8

                  [quote author="Andre" date="1319030027"]Trigger as in "show", yes. Your code does not trigger nor show, it only sets. [/quote]

                  I said My Bad, I'm sure you get things wrong too

                  1 Reply Last reply
                  0

                  4/8

                  19 Oct 2011, 04:57

                  • Login

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