Reputation: 95
I tried to make it like this :
QWidgetAction *labelAct = new QWidgetAction(screenMenu);
QLabel *label = new QLabel("sadas", screenMenu);
labelAct->setDefaultWidget(label);
screenMenu->addAction(labelAct);
but label is empty:
Upvotes: 1
Views: 1491
Reputation: 2995
Why don't you use just the void setIcon( const QIcon& icon )
function of the QAction
.
labelAct->setIcon( QIcon( "icon path" ) );
Upvotes: 0
Reputation: 27
you can use QLabel setPixmap() to set a pixmap
Something like:
QWidgetAction *labelAct = new QWidgetAction(screenMenu);
QLabel *label = new QLabel("sadas", screenMenu);
QPixmap mypix (":/test.png");
label->setPixmap(mypix);
labelAct->setDefaultWidget(label);
screenMenu->addAction(labelAct);
Upvotes: 1