View Full Version : Trouble setting toolbar widget palette

9th December 2009, 17:12

My program has a mainwindow with a number of toolbars. I want to add a toolbar that contains a QLabel displaying some text and would like the text to be, let's say, red.

What i'm doing:

QToolBar* tb = new QToolBar(this);

QLabel* label = new QLabel;
QPalette palette = label->palette();
palette.setColor(QPalette::WindowText, QColor("#FF0000"));

this->addToolBar(QT::TopToolBarArea, tb);

What i'm expecting: the toolbar text to be red.
What i'm getting: the toolbar text is not changing, at all.

Any thoughts? What am I doing wrong? Should I maybe set the text and the palette after construction has finished?

9th December 2009, 17:43
Further testing reveals that the problem is confined to certain window styles, ex: CDE, Motif and Cleanlooks.

Also, setting the palette of a label anywhere that isn't in a toolbar seems to work ok, regardless of the style.

Should this behavior be considered a bug or a feature?