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. Correct way to reset/unset a property
Forum Updated to NodeBB v4.3 + New Features

Correct way to reset/unset a property

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 719 Views 1 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    Is there a way to reset / unset a property so the system goes back to a state before setProperty has been called, psuedo example:

        setProperty("simon", someData);  //Assigns someData to the property "simon"
        unsetProperty("simon");  //Removes "simon" so it doesn't exist anymore.
    

    [Edit] I've created a QMap in my class instead of using properties to resolve this.

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #2

      Are you talking about dynamic properties? Then you can 'remove' them by just calling QObject::setProperty() by setting an invalid QVariant, e.g.

      setProperty("simon", someData);  //Assigns someData to the property "simon"
      setProperty("simon", QVariant());  //Removes "simon" so it doesn't exist anymore.
      

      Director R&D, The Qt Company

      SPlattenS 1 Reply Last reply
      2
      • kkoehneK kkoehne

        Are you talking about dynamic properties? Then you can 'remove' them by just calling QObject::setProperty() by setting an invalid QVariant, e.g.

        setProperty("simon", someData);  //Assigns someData to the property "simon"
        setProperty("simon", QVariant());  //Removes "simon" so it doesn't exist anymore.
        
        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @kkoehne , thank you, this could be implemented as a macro doing exactly that by improving readability.

        Kind Regards,
        Sy

        JonBJ 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @kkoehne , thank you, this could be implemented as a macro doing exactly that by improving readability.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @SPlatten
          Do stuff as inline functions instead of macros these days :)

          SPlattenS 1 Reply Last reply
          1
          • JonBJ JonB

            @SPlatten
            Do stuff as inline functions instead of macros these days :)

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            @JonB completely agree, I had exactly this conversation where I’m working suggesting the same.

            Kind Regards,
            Sy

            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