I'm creating a text editor and I'd like to put the QComboBox
in the QMenu
. I didn't find any method inside the QMenu
that handled such a thing. The closest is QMenu::addAction()
. I was wondering of getting around this hurdle.
Thanks!
I'm creating a text editor and I'd like to put the QComboBox
in the QMenu
. I didn't find any method inside the QMenu
that handled such a thing. The closest is QMenu::addAction()
. I was wondering of getting around this hurdle.
Thanks!
You can always use a
QWidget
orQFrame
as the Menu Widget, then put aQHBoxLayout
on it, and insert yourQWidgets
inside.You have to subclass
QWidgetAction
and then simply call theaddAction
to your menu.Example code for Spin Box Action with a label
Now simply create it and add it to your menu
QWidgetAction
is aQAction
that contains aQWidget
. You can use this to encapsulate yourQComboBox
and add it to your menu viaQMenu::addAction
.