Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Window flags equivalent to Qt::SubWindow?



  • Hi,
    I want to set window flags to QMessageBox such that I want to show title bar but none of the buttons like close, minmax, help, etc buttons on it.
    So I got the same results by using Qt::SubWindow as a window flag.
    But I am getting a qWarning() whenever the messagebox is displayed. The error is

    @setGeometry: Unable to set geometry 327x69+355+94 on QWidgetWindow/'QMessageBoxClassWindow'. Resulting geometry: 333x93+355+94 (frame: 0, 0, 0, 0, custom margin: 0, 0, 0, 0, minimum size: 327x69, maximum size: 327x69).@

    So I would like to know any other possible combination of flags which gives the same results?



  • Hi,

    this code

    @void Widget::on_pushButton_clicked()
    {
    QMessageBox dlg(this);

    Qt::WindowFlags flags = dlg.windowFlags();
    qDebug("FLAGS: %X", flags);
    flags &= ~Qt::WindowCloseButtonHint;
    flags &= ~Qt::WindowSystemMenuHint;
    flags |= Qt::CustomizeWindowHint;
    
    qDebug("FLAGS: %X", flags);
    dlg.setWindowFlags(flags);
    
    dlg.setIcon(QMessageBox::Information);
    dlg.setText("Hello");
    dlg.exec();
    

    }
    @

    works for me


Log in to reply