how to add qaction to the menu in qtoolbar
-
Did you mean add an
QActiontoQToolbar?toolbar = QToolBar("My main toolbar") self.addToolBar(toolbar) action = QAction("Your button", self) toolbar.addAction(action) -
@Ratzz said in how to add qaction to the menu in qtoolbar:
toolbar.addAction(action)
So QAction will be added to the toolBar, but I need to add it to the menu that opens when the right mouse button is clicked
@Mikeeeeee There are many addAction(...) methods in QMenu. Also see https://doc.qt.io/qt-5/qwidget.html#customContextMenuRequested
-
@Ratzz said in how to add qaction to the menu in qtoolbar:
toolbar.addAction(action)
So QAction will be added to the toolBar, but I need to add it to the menu that opens when the right mouse button is clicked
@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? -
@Mikeeeeee
Is that not exactly what the stackoverflow post I pointed you to addresses? -
@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 ?
-
I don't show my code because my code isn't there. I put widgets in the designer and the menu appeared automatically. Now I need to get a pointer to this menu.
@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....hfile (in the debug output folder) fromuic. Hopefully you will see how this menu is generated, and how you might access it.