Qt Forum

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

    Call for Presentations - Qt World Summit

    [Solved] Mouse area onClicked problem.

    QML and Qt Quick
    2
    3
    4328
    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.
    • N
      Natatos last edited by

      I'm trying follow "this tutorial":http://doc.qt.nokia.com/qtcreator-2.2/creator-qml-application.html but I'm getting an error "ReferenceError: Can't find variable: page" when I click the squares. Here's the code (I removed the first and second rectangles for this to make it shorter)
      @import QtQuick 1.0

      Rectangle {
      width: 360
      height: 400
      color: "#515151"

      Image {
          id: logo
          x: 33
          y: 22
          source: "qt.png"
      }
      
      Rectangle {
          id: middleRect
          x: 274
          y: 155
          width: 64
          height: 64
          color: "#00000000"
          radius: 6
          border.color: "#5f5f5f"
          border.width: 2
          MouseArea {
              id: mouse_area2
              anchors.fill: parent
              onClicked: page.state = 'State2'
          }
      }
      
      states: [
          State {
              name: "State1"
      
              PropertyChanges {
                  target: logo
                  x: middleRect.x
                  y: middleRect.y
              }
          },
          State {
              name: "State2"
          }
      ]
      

      }@

      Its at the line onClicked: page.state = 'State1' that I get the error.
      It was working last night when I tried but now its not. I don't know what to do.

      1 Reply Last reply Reply Quote 0
      • M
        mbrasser last edited by

        Hi,

        It looks like the top level Rectangle is missing its id (step 4.1 is where this is set).

        Regards,
        Michael

        1 Reply Last reply Reply Quote 0
        • N
          Natatos last edited by

          Ah there we go. Thanks for the help I new I was missing something.

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