Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80607

QToolButton continues to emit clicked() signal even after it is hidden

    XMLWordPrintable

Details

    • Android, Windows

    Description

      When the QToolButton (with auto-repeat) is made hidden while being pressed, it continues to call clicked() method forever.

      in the following example code, qDebug() continues to print "toolButtonClicked-count:" .. even after the button isVisible is false.

       

      #include <QToolButton>
      #include <QtDebug>
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          auto toolButton = new QToolButton(this) ;
          toolButton->setGeometry(10, 10, 100, 30) ;
          toolButton->setAutoRepeat(true) ;
          toolButton->setText(QString("Press this button until the toolButtonClicked-count message reaches 6")) ;
      
          connect(toolButton, &QToolButton::clicked, [=]
          {
              static int clickCount = 0 ;
      
              qDebug() << "toolButtonClicked-count: " << clickCount ;
      
              if(clickCount == 5)
                  toolButton->setVisible(false) ;
      
              clickCount++ ;
          }) ;
      }
      

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            anbu Ahmed Bedeer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes