Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.9.0
-
None
Description
Currently, Qt (Creator|Designer) requires QToolBar widgets to be unintuitively added by right-clicking the root QMainWindow widget and selecting "Add Tool Bar" from the resulting context menu. This non-orthogonality arguably constitutes poor UX and certainly complicates creation of multiple tool bars.
QToolBar widgets are reusable widgets like any other widgets and should ideally be treated as such. While there exist few use cases for adding QStatusBar or QMenuBar widgets to any container other than the root QMainWindow widget, there exist many valid use cases for adding QToolBar widgets to containers other than the root QMainWindow widget. To maximize window real estate and minimize screen clutter, modern UX design frequently allocates one unique tool bar for each top-level widget. In fact, Qt Creator itself features multiple tool bar-like QToolButton containers evenly distributed throughout its top-level widgets.
On my system, there currently appears to be no means of adding QToolBar widgets to containers other than the root QMainWindow widget from within Qt Creator itself. For unknown reasons, Qt Creator prohibits QToolBar widgets added via the "Add Tool Bar" context menu item from being moved to anywhere other than the conventional tool bar location (i.e., immediately under the menu bar).
That's kinda bad.
Hacky Workarounds that Work
Fortunately, manually hacking new QToolBar widgets into the internal XML content of the desired UI file from outside Qt Creator is trivial. Doing so requires elbow grease, grit, and a surly grimace, but actually works:
- Open the desired UI file in Qt Creator.
- Add a placeholder widget where you would prefer a new QToolBar widget.
- Save and close this file.
- Open this file in your editor of choice. vim, of course. Always vim.
- Find the <widget class="QToolBar" name="mainToolBar">...</widget> tag defining the default QToolBar widget.
- Copy the entirety of this tag into the clipboard. By which I mean a vim register, of course. Always vim.
- Find the <widget ...>...</widget> tag defining the previously added placeholder widget.
- Replace the entirety of this tag with the contents of the clipboard.
- Save and close this file.
Voilà! Instant QToolBar widgets wherever you like.
We Can Do Better than This, People
Nobody wants to hack XML every time they need a new QToolBar. Obviating that sort of boilerplate copypasta is the whole point of Qt Creator in the first place, right?
It would be vastly preferable to permit QToolBar widgets to be added in the same manner as any other widget. Ideally, the standard widget list should additionally list a new "Tool Bar" item (...perhaps under the existing Containers section?) and permit new QToolBar widgets to be dragged-and-dropped from this list item onto arbitrary locations of the current GUI.
Just like any other widget.
In any case, thanks for the long, gruelling years of dedication, Qt QA team! You guys rock.
Attachments
Issue Links
- is duplicated by
-
QTBUG-71366 Qt Designer: Need to be able to drag widgets into a QMainWindow's toolbar
- Reported