The 2-click issue disappears if I use clicked() for the pb connection instead of pressed() ... debug tells me that the pressed signal is NOT being emitted twice though, so no idea why using pressed() would have this side-effect. The reason I was using QPushButton:ressed instead ofQPushButton::clicked was because the "clicked" was not responsive, as though focus was being lost between the pressed and release actions.
//This called in MainWindow::Init() function
// If use QPushButton::pressed then 2 clicks required to close window
// If use QPushButton::clicked then the pb itself is not responsive
bConnected = connect(ui->pB_VerDlg, &QPushButton::pressed,this, &MainWindow::ShowVersionBox);
if (!bConnected) printf("failed to connect clicked() to ShowVersionBox()\n");
---
void MainWindow::ShowVersionBox() {
printf("======> Handling PB click\n");
msgBox.setWindowTitle("");
msgBox.setText("Applications List");
msgBox.setFont(fontBold);
msgBox.
setStyleSheet(QString::fromUtf8("background-color: rgb(0, 75, 141); color: white; "));
msgBox.
button(QMessageBox::Ok)->setMinimumSize
(QSize(70*HMI_SCALE,
40*HMI_SCALE
));
msgBox.setInformativeText("All info");
// Close box after 30s if left open
QTimer::singleShot(CLOSE_WINDOW_MS,
&msgBox,
SLOT(close
()));
msgBox.exec() ;
}
//This called in MainWindow::Init() function
// If use QPushButton::pressed then 2 clicks required to close window
// If use QPushButton::clicked then the pb itself is not responsive
bConnected = connect(ui->pB_VerDlg, &QPushButton::pressed,this, &MainWindow::ShowVersionBox);
if (!bConnected) printf("failed to connect clicked() to ShowVersionBox()\n");
---
void MainWindow::ShowVersionBox() {
QMessageBox msgBox;
printf("======> Handling PB click\n");
msgBox.setWindowTitle("");
msgBox.setText("Applications List");
msgBox.setFont(fontBold);
msgBox.setStyleSheet(QString::fromUtf8("background-color: rgb(0, 75, 141); color: white; "));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.button(QMessageBox::Ok)->setFont(fontBold);
msgBox.button(QMessageBox::Ok)->setMinimumSize(QSize(70*HMI_SCALE, 40*HMI_SCALE));
msgBox.setInformativeText("All info");
// Close box after 30s if left open
QTimer::singleShot(CLOSE_WINDOW_MS, &msgBox, SLOT(close()));
msgBox.exec() ;
}
To copy to clipboard, switch view to plain text mode
Bookmarks