Home > Blockchain >  Creating a QMessageBox without Button
Creating a QMessageBox without Button

Time:02-01

Despite setting setStandardButtons(0); it doesn't close the msgBox.

QMessageBox msgBox;
msgBox.setText("My List");
msgBox.setStyleSheet("QDialog { border: 1px solid black;}");
msgBox.setStandardButtons(0);
QTimer::singleShot(5000, &msgBox, SLOT(close()));
msgBox.exec();

CodePudding user response:

Use accept instead of close.

msgBox.setStandardButtons(QMessageBox::NoButton);
QTimer::singleShot(5000, &msgBox, &QMessageBox::accept);
  •  Tags:  
  • qt
  • Related