Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Dynamic properties not setted when using function return

    General and Desktop
    1
    1
    415
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Holt59 last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post