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 make a QTool tip show when a button is pressed / clicked
Forum Updated to NodeBB v4.3 + New Features

How to make a QTool tip show when a button is pressed / clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 5 Posters 2.2k 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.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by ManiRon
    #1

    I want to show the tool tip when the button is pressed and it must vanish after some time and again when i press the button it should be popped up. How can this be done ?

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

      hi
      #include <QToolTip>

      QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");

      ManiRonM 1 Reply Last reply
      3
      • ManiRonM ManiRon

        I want to show the tool tip when the button is pressed and it must vanish after some time and again when i press the button it should be popped up. How can this be done ?

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @ManiRon

        Connect a slot to the button::clicked signal, where you show your ToolTip-Text. The showText-function also contains a timeout-parameter

        https://doc.qt.io/qt-5/qtooltip.html#showText-2


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        2
        • mrjjM mrjj

          hi
          #include <QToolTip>

          QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");

          ManiRonM Offline
          ManiRonM Offline
          ManiRon
          wrote on last edited by
          #4

          @mrjj said in How to make a QTool tip show when a button is pressed / clicked:

          #include <QToolTip>
          QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");

          any sample code will be available so that i can understand better

          Pl45m4P 1 Reply Last reply
          0
          • ManiRonM ManiRon

            @mrjj said in How to make a QTool tip show when a button is pressed / clicked:

            #include <QToolTip>
            QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");

            any sample code will be available so that i can understand better

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by
            #5

            @ManiRon said in How to make a QTool tip show when a button is pressed / clicked:

            @mrjj said in How to make a QTool tip show when a button is pressed / clicked:

            #include <QToolTip>
            QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");

            any sample code will be available so that i can understand better

            Isnt that sample code?


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            ManiRonM 1 Reply Last reply
            2
            • Pl45m4P Pl45m4

              @ManiRon said in How to make a QTool tip show when a button is pressed / clicked:

              @mrjj said in How to make a QTool tip show when a button is pressed / clicked:

              #include <QToolTip>
              QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");

              any sample code will be available so that i can understand better

              Isnt that sample code?

              ManiRonM Offline
              ManiRonM Offline
              ManiRon
              wrote on last edited by ManiRon
              #6

              @Pl45m4 sorry i applied it at wrong place , Now it worked fine . but it just shows for some mili seconds i think so , Can we increase the display time of tool tip ?

              Pl45m4P 1 Reply Last reply
              0
              • ManiRonM ManiRon

                @Pl45m4 sorry i applied it at wrong place , Now it worked fine . but it just shows for some mili seconds i think so , Can we increase the display time of tool tip ?

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by
                #7

                @ManiRon

                @Pl45m4 said in How to make a QTool tip show when a button is pressed / clicked:

                The showText-function also contains a timeout-parameter
                https://doc.qt.io/qt-5/qtooltip.html#showText-2

                void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
                

                If you set msecDisplayTime to e.g. 3000, it will stay visible for 3 seconds


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                ManiRonM 2 Replies Last reply
                2
                • Pl45m4P Pl45m4

                  @ManiRon

                  @Pl45m4 said in How to make a QTool tip show when a button is pressed / clicked:

                  The showText-function also contains a timeout-parameter
                  https://doc.qt.io/qt-5/qtooltip.html#showText-2

                  void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
                  

                  If you set msecDisplayTime to e.g. 3000, it will stay visible for 3 seconds

                  ManiRonM Offline
                  ManiRonM Offline
                  ManiRon
                  wrote on last edited by
                  #8

                  @Pl45m4 thanks i got it .

                  1 Reply Last reply
                  0
                  • Pl45m4P Pl45m4

                    @ManiRon

                    @Pl45m4 said in How to make a QTool tip show when a button is pressed / clicked:

                    The showText-function also contains a timeout-parameter
                    https://doc.qt.io/qt-5/qtooltip.html#showText-2

                    void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
                    

                    If you set msecDisplayTime to e.g. 3000, it will stay visible for 3 seconds

                    ManiRonM Offline
                    ManiRonM Offline
                    ManiRon
                    wrote on last edited by
                    #9

                    @Pl45m4 @mrjj

                      QRect rect;
                      rect.setHeight(ui->pushbutton->height());
                      rect.setWidth(ui->pushbutton->width());
                    
                       QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,0,rect,3000);
                    

                    the tool tip is not showing till what ever time i have specified ? any change i have to make

                    jsulmJ Pl45m4P 2 Replies Last reply
                    0
                    • ManiRonM ManiRon

                      @Pl45m4 @mrjj

                        QRect rect;
                        rect.setHeight(ui->pushbutton->height());
                        rect.setWidth(ui->pushbutton->width());
                      
                         QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,0,rect,3000);
                      

                      the tool tip is not showing till what ever time i have specified ? any change i have to make

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @ManiRon said in How to make a QTool tip show when a button is pressed / clicked:

                      the tool tip is not showing till what ever time i have specified ?

                      What do you mean? You want to have a delay before showing the tool tip? If so then why not using QTimer?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      ManiRonM 1 Reply Last reply
                      0
                      • ManiRonM ManiRon

                        @Pl45m4 @mrjj

                          QRect rect;
                          rect.setHeight(ui->pushbutton->height());
                          rect.setWidth(ui->pushbutton->width());
                        
                           QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,0,rect,3000);
                        

                        the tool tip is not showing till what ever time i have specified ? any change i have to make

                        Pl45m4P Offline
                        Pl45m4P Offline
                        Pl45m4
                        wrote on last edited by
                        #11

                        @ManiRon

                        Check your parameters... you have no Text-parameter there...

                        QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "MY_TOOLTIP", qTable, rect,3000);
                        

                        What is qTable in your case?


                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                        ~E. W. Dijkstra

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

                          Hi
                          Works on linux and windows for me. (Qt 5.9)
                          it stays the time you tell it.
                          Do note however, you CANNOT click on the screen in the meantime. then it goes away at once.

                          ManiRonM 2 Replies Last reply
                          2
                          • Pl45m4P Pl45m4

                            @ManiRon

                            Check your parameters... you have no Text-parameter there...

                            QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "MY_TOOLTIP", qTable, rect,3000);
                            

                            What is qTable in your case?

                            ManiRonM Offline
                            ManiRonM Offline
                            ManiRon
                            wrote on last edited by ManiRon
                            #13

                            @Pl45m4

                            qTable is my text

                            1 Reply Last reply
                            0
                            • mrjjM mrjj

                              Hi
                              Works on linux and windows for me. (Qt 5.9)
                              it stays the time you tell it.
                              Do note however, you CANNOT click on the screen in the meantime. then it goes away at once.

                              ManiRonM Offline
                              ManiRonM Offline
                              ManiRon
                              wrote on last edited by
                              #14

                              @mrjj no I am not clicking any where , still it is not showing for the specified time and also i will be showing some status in the tool tip which will be updated in a particular time period how can this be done ?

                              1 Reply Last reply
                              0
                              • mrjjM mrjj

                                Hi
                                Works on linux and windows for me. (Qt 5.9)
                                it stays the time you tell it.
                                Do note however, you CANNOT click on the screen in the meantime. then it goes away at once.

                                ManiRonM Offline
                                ManiRonM Offline
                                ManiRon
                                wrote on last edited by
                                #15

                                @mrjj it display the tool tip only for few milli seconds , is there something wrong i am doing ?

                                      QRect rect;
                                rect.setHeight(ui->pushbtn->height());
                                rect.setWidth(ui->pushbtn->width());
                                
                                QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,ui->pushbtn,rect,5000);
                                
                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @ManiRon said in How to make a QTool tip show when a button is pressed / clicked:

                                  the tool tip is not showing till what ever time i have specified ?

                                  What do you mean? You want to have a delay before showing the tool tip? If so then why not using QTimer?

                                  ManiRonM Offline
                                  ManiRonM Offline
                                  ManiRon
                                  wrote on last edited by
                                  #16

                                  @jsulm No i want to show tool tip till some period of time

                                  1 Reply Last reply
                                  0
                                  • Christian EhrlicherC Offline
                                    Christian EhrlicherC Offline
                                    Christian Ehrlicher
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    Maybe related to https://bugreports.qt.io/browse/QTBUG-18520

                                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                    Visit the Qt Academy at https://academy.qt.io/catalog

                                    ManiRonM 1 Reply Last reply
                                    1
                                    • Christian EhrlicherC Christian Ehrlicher

                                      Maybe related to https://bugreports.qt.io/browse/QTBUG-18520

                                      ManiRonM Offline
                                      ManiRonM Offline
                                      ManiRon
                                      wrote on last edited by
                                      #18

                                      @Christian-Ehrlicher

                                             QRect rect;
                                      rect.setHeight(ui->pushbtn->height());
                                      rect.setWidth(ui->pushbtn->width());
                                      this->setToolTipDuration(5000);
                                      QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,this,rect,5000);
                                      

                                      tried something like this but no change

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

                                        Hi
                                        What Qt version are you using?
                                        It works for me with Qt5.9/5.13 on Windows and Linux.

                                        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