PDA

View Full Version : QLabel not showing



MarkoSan
14th April 2008, 22:51
Hi to all again!

I have a small nasty error. I have this code chunk:
// label creation
m_pTotalLabel=new QLabel(tr("SKUPAJ:"), this); // creates new label
Q_CHECK_PTR(m_pTotalLabel); // checks creation
//m_pTotalLabel->setFrameStyle(QFrame::Panel | QFrame::Raised);
m_pTotalLabel->setAutoFillBackground(true);
QPalette TotalFieldPalette=m_pTotalLabel->palette(); // gets current pallete of current widget
TotalFieldPalette.setColor(QPalette::Base, Qt::black); // sets backgorund color of widget
TotalFieldPalette.setColor(QPalette::Text, Qt::white); // sets foreground color of widget
m_pTotalLabel->setPalette(TotalFieldPalette); // sets palette
m_pTotalLayout->addWidget(m_pTotalLabel); // adds widget to layout
// **** end of label creation

Well, the label is not shown. Why???!!!

MarkoSan
14th April 2008, 22:58
Well, god damn, sloppy again. Instead of

TotalFieldPalette.setColor(QPalette::Text, Qt::white); // sets foreground color of widget one must use
TotalFieldPalette.setColor(QPalette::WindowText, Qt::white); // sets foreground color of widget