how to add qaction to the menu in qtoolbar
-
Did you mean add an
QAction
toQToolbar
?toolbar = QToolBar("My main toolbar") self.addToolBar(toolbar) action = QAction("Your button", self) toolbar.addAction(action)
-
@Mikeeeeee There are many addAction(...) methods in QMenu. Also see https://doc.qt.io/qt-5/qwidget.html#customContextMenuRequested
-
@Mikeeeeee
So search the https://doc.qt.io/qt-5/qmenu.html page for all theaddAction()
methods?But I don't think that's what you mean. Can't run Qt right now, but if you say there is a menu when you right-click a
QToolbar
, does How to add an entry to toolbar context menu in qt? answer what you want to do? -
@JonB said in how to add qaction to the menu in qtoolbar:
Is that not exactly what the stackoverflow post I pointed you to addresses?
That's not it. I already have a menu in the toolbar. The menu is created automatically. How can I get a pointer to a menu and add qaction to it?
-
Hi,
What do you have currently in that drop down menu ?
How are your initialization that toolbar ?
What exactly is your goal with these additional actions ? -
Then add the the other dock widgets toggle actions to it.
-
The same way you did for the other dock widget.
-
Well, something different.
Seriously, how do you except to get an answer when you do not show your code, do not explain what you tried, in fact just nothing ?
-
@Mikeeeeee said in how to add qaction to the menu in qtoolbar:
the menu appeared automatically
This is not magic. You can learn an awful lot by looking at the code generated into the
ui....h
file (in the debug output folder) fromuic
. Hopefully you will see how this menu is generated, and how you might access it.