MessageBox closing Error ?
-
I wrote this code , and i'm pressing the back button on the messagebox doesn't close the mesagebox but shows the messagebox again. A second click closes the messagebox.
QMessageBox msg(this);
msg.setWindowFlags( Qt::Window | Qt::FramelessWindowHint);
msg.setStyleSheet("font: 75 20pt Liberation Serif ;");
QPixmap p("/home/pi/git/Updates/UI/img/Shield.png");
auto newPixmap = p.scaled(80, 80);
msg.setIconPixmap(newPixmap);
QFont font;
font.setBold(true);
msg.setFont(font);
msg.setText(" Quality Check - 405 nm \n\n Run Distilled Water");
msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msg.setButtonText(QMessageBox::Ok , "Run");
msg.setButtonText(QMessageBox::Cancel , "Back");
msg.setFixedWidth(500);
if(msg.exec() == QMessageBox::Ok)
{
ui->stackedWidget->setCurrentIndex(1);
}
else
{
ui->stackedWidget->setCurrentIndex(1);
}The messagebox should be closed on the first click.
how to write it? -
I wrote this code , and i'm pressing the back button on the messagebox doesn't close the mesagebox but shows the messagebox again. A second click closes the messagebox.
QMessageBox msg(this);
msg.setWindowFlags( Qt::Window | Qt::FramelessWindowHint);
msg.setStyleSheet("font: 75 20pt Liberation Serif ;");
QPixmap p("/home/pi/git/Updates/UI/img/Shield.png");
auto newPixmap = p.scaled(80, 80);
msg.setIconPixmap(newPixmap);
QFont font;
font.setBold(true);
msg.setFont(font);
msg.setText(" Quality Check - 405 nm \n\n Run Distilled Water");
msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msg.setButtonText(QMessageBox::Ok , "Run");
msg.setButtonText(QMessageBox::Cancel , "Back");
msg.setFixedWidth(500);
if(msg.exec() == QMessageBox::Ok)
{
ui->stackedWidget->setCurrentIndex(1);
}
else
{
ui->stackedWidget->setCurrentIndex(1);
}The messagebox should be closed on the first click.
how to write it?@Ramkumar-Mohan
Please learn to put blocks of code inside Code tags to make it easier for others to read, thank you.Use a debugger/
qDebug()statements to verify it returns on first click and follows theelseroute in your code. Assuming so, what happens after that? -
@Ramkumar-Mohan
Please learn to put blocks of code inside Code tags to make it easier for others to read, thank you.Use a debugger/
qDebug()statements to verify it returns on first click and follows theelseroute in your code. Assuming so, what happens after that?@JonB Ok Thank you.