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 693 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.
  • N Offline
    N Offline
    Nando
    wrote on 25 Sept 2020, 07:14 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 25 Sept 2020, 08:09
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 25 Sept 2020, 07:22 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 25 Sept 2020, 07:38
      0
      • B Offline
        B Offline
        Bob64
        wrote on 25 Sept 2020, 07:38 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
        • S sierdzio
          25 Sept 2020, 07:22

          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 25 Sept 2020, 07:38 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 25 Sept 2020, 07:40
          0
          • N Nando
            25 Sept 2020, 07:38

            @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 25 Sept 2020, 07:40 last edited by
            #5

            @Nando can you show the code what you did

            B 1 Reply Last reply 25 Sept 2020, 07:46
            0
            • S shashikumar
              25 Sept 2020, 07:40

              @Nando can you show the code what you did

              B Offline
              B Offline
              Bob64
              wrote on 25 Sept 2020, 07:46 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • N Nando
                25 Sept 2020, 07:14

                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 25 Sept 2020, 08:09 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

                1/7

                25 Sept 2020, 07:14

                • Login

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