View Full Version : QToolbar inside QWidget

14th February 2011, 13:50
If I have a QMainWindow, I can add toolbars and they look like this:


I have 3 toolbars, and their size can be changed with that line at the start of each.

However, I have a QWidget, and I would like to get the same effect. Is there a way to achieve this?

14th February 2011, 17:53
You can use any QWidget as the parent of a QToolBar. However, if you want all of the same behavior as the toolbars in a QMainWindow (floating, docking, automatic resizing of the other widgets on docking or floating, etc.), then you have to copy the code from QMainWindow that manages toolbars and docking. See the documentation and source code for QToolBar::setAllowedAreas() to see the communication between the toolbar and the main window.