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. show tooltip when the button is pressed
Forum Updated to NodeBB v4.3 + New Features

show tooltip when the button is pressed

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

    Hi, I am working on a project that has a lot of buttons on it for each of the different lights that I would be controlling. For each of the light I want to display some information using a tooltip. With the settooltip() command, it doesnt display the tooltip as soon as the button is pressed. It just displays when the mouse is hovered on the button.
    Since I am using a touch screen, there wont be any mouse to hover with. Hence please give me some advice on how to display the tooltip when the button is pressed and when the button is released there is no tooltip.

    Taz742T 1 Reply Last reply
    0
    • J jkprog

      Hi, I am working on a project that has a lot of buttons on it for each of the different lights that I would be controlling. For each of the light I want to display some information using a tooltip. With the settooltip() command, it doesnt display the tooltip as soon as the button is pressed. It just displays when the mouse is hovered on the button.
      Since I am using a touch screen, there wont be any mouse to hover with. Hence please give me some advice on how to display the tooltip when the button is pressed and when the button is released there is no tooltip.

      Taz742T Offline
      Taz742T Offline
      Taz742
      wrote on last edited by
      #2

      @jkprog
      https://stackoverflow.com/questions/44994288/qt-qpushbutton-press-event
      https://stackoverflow.com/questions/20722823/qt-get-mouse-pressed-event-even-if-a-button-is-pressed
      https://stackoverflow.com/questions/33671689/mouse-press-event-inside-qpushbutton-in-qt

      Do what you want.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jkprog
        wrote on last edited by
        #3

        That means one way of achieving this is to use the connect function?
        I tried using connect(), but i am probably not using it in the correct manner..

        connect(ui->Button1,SIGNAL(pressed),SLOT(ui->Button1->setToolTip("This is a tooltip");));
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Your connect statement is wrong on several levels. Your SIGNAL part misses the parenthesis and your SLOT statement is just plain wrong. If you want to do it like that, then use a lambda.

          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
          • SeenuS Offline
            SeenuS Offline
            Seenu
            wrote on last edited by
            #5

            @jkprog

            To the below connect statement have one slot for ex:-

            public slots:
            void catch_and_settooltip(); in .h file

            connect(ui->Button1,SIGNAL(pressed),this,SLOT(catch_and_settooltip()));

            void catch_and_settooltip()
            {
            Button1->setToolTip("This is a tooltip");
            }

            hope this will meet your requirement

            Taz742T 1 Reply Last reply
            0
            • SeenuS Seenu

              @jkprog

              To the below connect statement have one slot for ex:-

              public slots:
              void catch_and_settooltip(); in .h file

              connect(ui->Button1,SIGNAL(pressed),this,SLOT(catch_and_settooltip()));

              void catch_and_settooltip()
              {
              Button1->setToolTip("This is a tooltip");
              }

              hope this will meet your requirement

              Taz742T Offline
              Taz742T Offline
              Taz742
              wrote on last edited by Taz742
              #6

              @Seenu
              You are wrong.
              When you press the button you will be able to set the tooltip.
              But "show tooltip when the button is pressed", text will be shown when your button is presed.

              Do what you want.

              1 Reply Last reply
              0
              • Vinod KuntojiV Offline
                Vinod KuntojiV Offline
                Vinod Kuntoji
                wrote on last edited by Vinod Kuntoji
                #7

                @jkprog ,

                m_Button = new QPushButton("Click");
                connect(m_Button,SIGNAL(clicked()),this,SLOT(showToolTip()));
                

                void Widget::showToolTip() {
                QToolTip::showText(m_Button->mapToGlobal(QPoint()),"Click",m_Button);
                }

                C++, Qt, Qt Quick Developer,
                PthinkS, Bangalore

                1 Reply Last reply
                3

                • Login

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