QToolBar not available from Design UI
-
Hello. I was checking out Qt terminal example:
And noticed QToolBar widget that looked good and I would like to add this widget in my application, however, it is not available to select from the UI design window:
Is there any way to import this widget?
-
Hello. I was checking out Qt terminal example:
And noticed QToolBar widget that looked good and I would like to add this widget in my application, however, it is not available to select from the UI design window:
Is there any way to import this widget?
@lukutis222
In DesignerQToolBar
is only available on aQmainWindow
. See https://forum.qt.io/topic/82936/how-to-create-toolbar-in-design-created-by-qt-designer-design-creation-is-started-from-qwidget . -
Ah what a bummer. When I started making my application, I was not aware of differences between two. Main Window is much more suitable for making applications I guess.
-
Ah what a bummer. When I started making my application, I was not aware of differences between two. Main Window is much more suitable for making applications I guess.
@lukutis222
Well, main window is more suitable if (and only if) you want the facilities of a main window! Did you see the diagram at https://doc.qt.io/qt-6/qmainwindow.html#qt-main-window-framework ? -
@lukutis222
Well, main window is more suitable if (and only if) you want the facilities of a main window! Did you see the diagram at https://doc.qt.io/qt-6/qmainwindow.html#qt-main-window-framework ?@JonB
Now I have. I now understand that main window is definately more suitable for my application. Its not too late to move all my code form widget class to mainwindow so its not a problem.. Thank you :) -
@JonB
Now I have. I now understand that main window is definately more suitable for my application. Its not too late to move all my code form widget class to mainwindow so its not a problem.. Thank you :)@lukutis222
AQMainWindow
is simply a specializedQWidget
with the added "furniture" shown in the docs diagram. If you want any of menu, toolbar, docks or status bar it gives them (optionally) to you. It would be usual to have only oneQMainWindow
in an application, because it is for the main window! You may have further widgets, dialogs etc., or maybe your application is so simple it just has a main window and that is all.Don't forget that a
QMainWindow
has one "central widget", apart from its "furniture". What you were designing as aQWidget
may be suitable for that widget. -
@JonB
Now I have. I now understand that main window is definately more suitable for my application. Its not too late to move all my code form widget class to mainwindow so its not a problem.. Thank you :)@lukutis222
Don't use QWidget as top level widget.
Always use QMainWindow for main application window and document windows.
Otherwise use QDialogs.