[Solved] QMainWindow inside QMdiSubWindow



  • Hi,
    I am creating an application where the application's main window had a QMdiArea. Now i want to assign another mainwindow inside each of the QSubWindows

    @
    QMdiSubWindow* subWindow = new QMdiSubWindow();
    subWindow->setMinimumSize(200,100);
    editorWindow mainWindow; //inherits QMainWindow
    subWindow->setWidget(mainwindow);
    myMdiArea->addSubWindow(subWindow);
    subWindow->show();
    @

    This fails because im trying to assign window instead of widget. Please suggest what should I do ?

    Appreciate your help.



  • Hello,

    If editorWindow mainWindow inherits the QMainWindow, and you don't want to use the pointer syntax, you need to call
    @
    subWindow->setWidget(&mainwindow);
    @
    or
    @
    editorWindow *mainwindow = new editorWindow()
    subWindow->setWidget(mainwindow);
    @



  • I agree with gmaro.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.