sumit kang
sumit kang

Reputation: 476

Creating a QMessageBox without Button

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();

Upvotes: 3

Views: 2147

Answers (1)

Summit
Summit

Reputation: 2268

Use accept instead of close.

msgBox.setStandardButtons(QMessageBox::NoButton);
QTimer::singleShot(5000, &msgBox, &QMessageBox::accept);

Upvotes: 6

Related Questions