Qt4: Placing QMainWindow instance inside other QWidget/QMainWindow

后端 未结 3 1884
感情败类
感情败类 2021-01-05 07:11

I\'d like to place QMainWindow instance inside another QWidget (for example centralWidget of another QMainWindow).

I\'m wondering why it doesn\'t work ? QMainWindow

3条回答
  •  醉话见心
    2021-01-05 07:34

    Having the same problem, I found the solution here.

    QMainWindow sets its window type to Qt::Window so that it will be in an independent window even if it has a parent (you can confirm this by calling show() on your QMainWindow, and you will see it in its own window). Try adding the line

    window->setWindowFlags(Qt::Widget);
    

    after you construct the QMainWindow.

提交回复
热议问题