PDA

View Full Version : QAction text color (QMenu)



StefanK
20th March 2009, 14:34
Hello

I would like to set the text (foreground) color of an QAction on a QMenu.
I don't find out how that works.

Best Regards
Stefan

Hiker Hauk
20th March 2009, 16:14
One possible way. The idea below is to use a widget as a menu item, so that the text property can be customized.



QWidgetAction *newAct = new QWidgetAction(this);
QLabel *label = new QLabel(tr("New"));
label->setStyleSheet("color: red");
newAct->setDefaultWidget(label);
newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file"));
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));