Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dynamic properties not setted when using function return
QtWS25 Last Chance

Dynamic properties not setted when using function return

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 484 Views
  • 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 Offline
    H Offline
    Holt59
    wrote on last edited by
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved