Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Setting property not setting the value

Setting property not setting the value

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 852 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.
  • N Offline
    N Offline
    Nando
    wrote on last edited by Nando
    #1

    Hi,
    i have something like this

    RowLayout {
        MyButton {
            id: b1
            visible: false
        }
        MyButton {
            id: b2
            visible: false
        }
    // ...
    }
    

    then in a javascript function i set the 'visible' property and directly log it out and it is not changed, why?

    function test() {
        let newValue = true
        console.debug("newValue: ", newValue) // prints true -> correct
        b1.visible = newValue
        console.debug("newValue: ", b1.visible) // prints false -> wrong! why?
    }
    

    It seems when setting the visible property and then getting it is not set?
    Maybe somebody can explain me what's going on here, please ?

    Greetings
    Nando

    S 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Why is there a dot behind both of your debug calls?

      Apart from that - it should work, your code seems correct to me.

      (Z(:^

      N 1 Reply Last reply
      0
      • B Offline
        B Offline
        Bob64
        wrote on last edited by
        #3

        I had a similar issue last week setting x and y on a Popup. I posted a question in the forum (see here) but no-one answered.

        If this is known and expected behaviour, it really ought to be documented and explained more prominently somewhere. If it's not expected, what is going on?

        1 Reply Last reply
        0
        • sierdzioS sierdzio

          Why is there a dot behind both of your debug calls?

          Apart from that - it should work, your code seems correct to me.

          N Offline
          N Offline
          Nando
          wrote on last edited by
          #4

          @sierdzio said in Setting property not setting the value:

          Why is there a dot behind both of your debug calls?

          Apart from that - it should work, your code seems correct to me.

          That dot is type, sorry....
          Hmmm Okay i have MyButton inside a Layout...Maybe
          the layout somehow overwrites the visible ?

          S 1 Reply Last reply
          0
          • N Nando

            @sierdzio said in Setting property not setting the value:

            Why is there a dot behind both of your debug calls?

            Apart from that - it should work, your code seems correct to me.

            That dot is type, sorry....
            Hmmm Okay i have MyButton inside a Layout...Maybe
            the layout somehow overwrites the visible ?

            S Offline
            S Offline
            shashikumar
            wrote on last edited by
            #5

            @Nando can you show the code what you did

            B 1 Reply Last reply
            0
            • S shashikumar

              @Nando can you show the code what you did

              B Offline
              B Offline
              Bob64
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • N Nando

                Hi,
                i have something like this

                RowLayout {
                    MyButton {
                        id: b1
                        visible: false
                    }
                    MyButton {
                        id: b2
                        visible: false
                    }
                // ...
                }
                

                then in a javascript function i set the 'visible' property and directly log it out and it is not changed, why?

                function test() {
                    let newValue = true
                    console.debug("newValue: ", newValue) // prints true -> correct
                    b1.visible = newValue
                    console.debug("newValue: ", b1.visible) // prints false -> wrong! why?
                }
                

                It seems when setting the visible property and then getting it is not set?
                Maybe somebody can explain me what's going on here, please ?

                Greetings
                Nando

                S Offline
                S Offline
                shashikumar
                wrote on last edited by
                #7

                @Nando I tried this same code using rectangle, Test() is absolutely fine and it also not because of Layout

                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