Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Cannot assign to non-existent property "states" (solved)

    QML and Qt Quick
    4
    4
    4531
    Loading More Posts
    • 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
      houmingc last edited by

      Trying to use state in QML.
      getting error: cannot assign to non-existent property "states".
      Please help

      @
      import QtQuick 2.2
      import QtQuick.window 2.1
      window {

             id: myRect
             visible:true
             width:350
             height:350
             color:"red"
      
      
            MouseArea{
                       anchors.fill:parent
                       onClicked:myRect.state="moved"
                               }
          states:[
          State {
                          name: "moved"
                          PropertyChanges { target:myRect;   x:50   y:50   }
                    }
                    ]
      

      @

      1 Reply Last reply Reply Quote 0
      • M
        maxim.prishchepa last edited by

        what is "window"?
        maybe you should use "Window" ?
        QML is case sencetive...

        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

        A 1 Reply Last reply Reply Quote 0
        • A
          Aros @maxim.prishchepa last edited by

          @maxim.prishchepa Sorry to resurrect this thread after so long, but I believe this should not work even if the Window is spelled correctly. The thing is that I believe you cannot use states with Window object at all (although it is not mentioned anywhere in the documentation, which really drives me nuts, cause I just wasted a lot of time trying to find out). How come the thread is marked as solved even though it has no final answer?

          1 Reply Last reply Reply Quote 0
          • X
            xalam last edited by

            That's right, I think states doesn't work in Window. I learned the hard way as well but does anyone know why it doesn't work?

            1 Reply Last reply Reply Quote 0
            • First post
              Last post