-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.5
-
None
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++ ;
}) ;
}