[SOLVED] Embedded QMainWindow-deriven widget in application



  • I would like to have a widget, deriven from QMainWindow in my application. So I can add toolbars, and menus. Or may be somehow add toolbars to my custom widget (derived from any possible class). Toolbars should behave like a mainwindows's toolbar.



  • This image may be more descriptive. See the widget on the right bottom:

    !http://s3.picofile.com/file/7391041826/sc3.png(Imaginary)!



  • Still have no idea about how to implement...



  • I see, you want to embedding a instance of QMainWindow into a normal QWidget. In other words, you don't want to show it as a seperated window.

    So just
    @
    mw->setWindowFlags(mw->windowFlags() & ~Qt::Window);
    @

    Or, You even do not need QMainWindow for such a simple widget contains QMenuBar.

    As QMenuBar, QToolBar and QStatusBar are subclass of QWidget, you can put them to a normal QWidget, the same as you put a QPushButton onto it.



  • [quote author="1+1=2" date="1338136412"]
    Or, You even do not need QMainWindow for such a simple widget contains QMenuBar.

    As QMenuBar, QToolBar and QStatusBar are subclass of QWidget, you can put them to a normal QWidget, the same as you put a QPushButton onto it.
    [/quote]

    Yes, but toolbars won't move around and they will loss their dockablity. Also that small context menu that allows us to choose which toolbar should be show, is no more available.

    First solution looks more convenient but have problems. Size grip is still there. And trying to adjust size of embedded MW will resize whole application :-/



  • I think that "Size grip " will disappear if you didn't create a QStatusBar.



  • Nicely works
    You saved my day, again ;)
    Thanks


Log in to reply
 

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