Dynamic properties not setted when using function return
-
I'm facing a strange issue in my Qt application... I have a Widget inheriting QLabel with the following stylesheet:
@QLabel { padding: 10px ; }
QLabel[current-player=true] { background: blue ; }
QLabel:disabled { background: #eee ; }@And a method:
@void MyWidget::updateInformation () {
this->setEnabled (m_player->isEnable ());
this->setProperty ("current-player", m_player->isCurrentPlayer ());
// this->setProperty ("current-player", true);
qDebug () << "Property current player: " << this->property ("current-player");
}@As you can see, I want to set the background of my widget to blue when the current-player property is true, so I have the conditions m_player->isCurrentPlayer().
I have a line commented, which was used to test if the property worked, and it did. When I uncomment the line, the background becomes blue.
What is strange is that my debug output is (when the line is commented):
@Property current player: QVariant(bool, false)
Property current player: QVariant(bool, true)
Property current player: QVariant(bool, true)@As you can see, the isCurrentPlayer method return true, but the background stay white...
I don't understand my the code works when I set the property all the time and doesn't work if I set the property using a return from my method.
If anyone as an idea, it'll help me a lot!
Thanks!