I'm trying to insert a QWidgetAction
inside a QMenu
, which will be used as a context menu for tray. When I do this, I only get an empty line inside my menu.
I'm using:
- Qt 5.5.1.
- Plasma 5 desktop environment (Linux).
Here is my code:
action = new QWidgetAction(0);
testw = new QWidget();
testl = new QLabel(QString("Test"), testw);
action->setDefaultWidget(testw);
menu.addAction(action);
trayIcon.setContextMenu(&menu);
If I use menu.addAction(QString("Test"))
; it is displayed properly.
All the variables are members of my class.