QDialog without tab in taskbar
1 answer
You need to specify a parent window for QMessageBox
:
QApplication a(argc, argv);
qt_test_dialog w;
w.show();
// with additional button
// QMessageBox box(QMessageBox::Information, "Title", "Hello there!", QMessageBox::Ok);
// without additional button!
QMessageBox box(QMessageBox::Information, "Title", "Hello there!", QMessageBox::Ok, &w);
Or simply:
QMessageBox box(&w);
box.setText("Hello");
box.exec();
Please note that the parent parameter can be empty QWidget
:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// plain wrong (you will not be able to exit application) - but it demonstrates
// the case
QMessageBox box(new QWidget());
box.setText("Hello");
box.exec();
return a.exec();
}
+3
source to share