[SOLVED] How do I add a QToolButton to a QToolBar in design mode in Qt Creator?


Design mode on a form of a MainWindow (derived from QMainWindow) does not allow one (in any way I can see) to add a tool button to a tool bar that has been added to the main window.

If I try drag and drop from the widgets panel, I get a "Not allowed" symbol (on Linux, behavior similar on Mac) – I can’t drop the tool button on to the tool bar (I took a screenshot, but it is not informative because the "Not allowed" cursor symbol is not shown in the screenshot).

If I right-click on the tool bar, the context menu that pops up has options to append a separator, promote the QToolBar, or remove the tool bar. No option to add a tool button. context menu shown in this image

I have a pretty good idea of how I could add a QToolButton programmatically (unless I misunderstand how QToolBar is supposed to work), but I would prefer that I understand how to use design mode properly.

Thanks for any help.


For adding one tool button to toolBar you should :

  1. Create one Action like this (Go to Action Editor Tab and select New Button) :

enter image description here

  1. This Action is your tool button so Create Name and Icon and …

enter image description here

  1. Drag that Action and then Drop it in ToolBar like this

enter image description here

Answered By – Parisa.H.R

Answer Checked By – Gilberto Lyons (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *