Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Clear Dynamic Properties
Forum Updated to NodeBB v4.3 + New Features

Clear Dynamic Properties

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 1.4k Views 2 Watching
  • 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.
  • K Offline
    K Offline
    kumararajas
    wrote on last edited by
    #1

    Hello all,

    As I am aware, I can set the dynamic properties by using setProperty function.

    For example, I would have a stylesheet which appears to be like this -
    QLabel[BlueColorLabel=true]
    {
    background-color:rgb(240,30,10);
    }

    QLabel[YellowColorLabel=true]
    {
    background-color:rgb(230,30,0);
    }

    So, in my code I would set something like
    myLabel->setProperty("BlueColorLabel", "true");

    During run time, if I want change the color of my label, I may have to do something like this
    myLabel->setProperty("BlueColorLabel", "false");
    myLabel->setProperty("YellowColorLabel", "true");

    This would remove the previous property and set the new one.

    Here is my question.
    Here I know the property value, so I could easily set it to false.

    Is there a way that will help me to clear all properties without specifying them or even without knowing them?

    Thank you,
    Kumara

    --Kumar

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Use dynamicPropertyNames to get all dynamic properties and then loop through and call setProperty with an invalid QVariant to remove them.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • K Offline
        K Offline
        kumararajas
        wrote on last edited by
        #3

        Hi Sam,

        After I ask the question, I exactly tried the same dynamicPropertyNames and achieved the result I wanted.

        Thank you!

        --Kumara

        --Kumar

        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