Important: Please read the Qt Code of Conduct -

QMdiSubWindow: is it possible to add menu strip?

  • Hi ALL,
    I have created a MDI interface with several sub windows (QMdiSubWindow).
    I want to add menu bar at the top but form editor does not allow me to do that.
    It is probably because QMdiSubWindow window is inherited from QWidget?
    Cant i implement that?

  • Lifetime Qt Champion

    menu strip is menu bar ? like MainWindow has ?
    While you cannot do it in Design mode, it is possible to insert such menu
    via code. However, you need to add a layout also to keep it at top .


    void MainWindow::on_pushButton_released()
        // create new window
        QMdiSubWindow *subWindow1 = new QMdiSubWindow(ui->mdiArea);
        subWindow1->resize(300, 100);
        // create new widget for the mdi window ( the inner ) 
        QWidget *myWidget = new QWidget(subWindow1);
        // make layout and a menu bar
        QVBoxLayout *boxLayout = new QVBoxLayout(myWidget);
        QMenuBar *menuBar = new QMenuBar();
        QMenu *fileMenu = new QMenu("File");
        // assign menubar to widget
        // set widget to the MDI window

    alt text

  • Thanks a lot
    that is exactly what i needed
    It seems editor only allow to set menu bar to QMainWindow class :(

Log in to reply