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 6.8k 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 1 Aug 2017, 17:01 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.

    T 1 Reply Last reply 1 Aug 2017, 17:17
    0
    • J jkprog
      1 Aug 2017, 17:01

      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.

      T Offline
      T Offline
      Taz742
      wrote on 1 Aug 2017, 17:17 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 1 Aug 2017, 18:21 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 1 Aug 2017, 22:18 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
          • S Offline
            S Offline
            Seenu
            wrote on 4 Aug 2017, 08:54 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

            T 1 Reply Last reply 4 Aug 2017, 10:39
            0
            • S Seenu
              4 Aug 2017, 08:54

              @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

              T Offline
              T Offline
              Taz742
              wrote on 4 Aug 2017, 10:39 last edited by Taz742 8 Apr 2017, 10:59
              #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
              • V Offline
                V Offline
                Vinod Kuntoji
                wrote on 4 Aug 2017, 11:10 last edited by Vinod Kuntoji 8 Apr 2017, 11:43
                #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

                1/7

                1 Aug 2017, 17:01

                • Login

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