QDialog without tab in taskbar

The question is very simple. Can I show QDialog

or QMessageBox

without creating a tab for it in the taskbar? I tried to use exec (), show () functions, changing the modality value, but the tab is always on.

+3


source to share


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







All Articles