Quantcast
Channel: User spraff - Stack Overflow
Viewing all articles
Browse latest Browse all 45

Why does my QWidget stylesheet not recognise objectName rules?

$
0
0

Here I have a subclass of QComboBox which is going to change the colour of its text according to the validity of its contents.

namespace{    const QString GOOD = "good";    const QString BAD  = "bad";}NewDBLabel :: NewDBLabel( DB db, const QString & table ) :    m_db (db){    connect (this, SIGNAL (textChanged (const QString &)),            this,  SLOT   (changed     (const QString &)));    setStyleSheet ("QWidget#" + GOOD +" {color: black;} ""QWidget#" + BAD  +" {color: darkRed;}");}void NewDBLabel :: changed (const QString & label){    if (m_db .label_exists (m_table, label))    {        qWarning ("exists"); // this is printed correctly        setObjectName (BAD);        emit valid (false);    }    else    {        qWarning ("new"); // this is printed correctly        setObjectName (GOOD);        emit valid (true);    }}

As far as I can tell, this conforms to the documentation: QWidget#foo should match subclasses of QWidget whose objectName is foo.

I expected that setObjectName would cause the different style rules to be applied, but this doesn't happen. Any idea why?


Viewing all articles
Browse latest Browse all 45

Latest Images

Trending Articles





Latest Images