Hello!
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:
MyWindow::MyWindow()
{
label->setPalette(palette);
label->setText("wo0t");
tb->addWidget(label);
this->addToolBar(QT::TopToolBarArea, tb);
}
MyWindow::MyWindow()
{
QToolBar* tb = new QToolBar(this);
QLabel* label = new QLabel;
QPalette palette = label->palette();
palette.setColor(QPalette::WindowText, QColor("#FF0000"));
label->setPalette(palette);
label->setText("wo0t");
tb->addWidget(label);
this->addToolBar(QT::TopToolBarArea, tb);
}
To copy to clipboard, switch view to plain text mode
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?
Bookmarks