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. [Solved] Mouse area onClicked problem.
QtWS25 Last Chance

[Solved] Mouse area onClicked problem.

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 4.6k 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
    Natatos
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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
      0
      • N Offline
        N Offline
        Natatos
        wrote on last edited by
        #3

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

        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