Qt Forum

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

    Unsolved MouseArea Control Click Position Problem

    QML and Qt Quick
    2
    2
    544
    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.
    • M
      Mr .Wu last edited by

      The TP size of our equipment is 240240 . When I use the MouseArea control to respond to the click event . the mousearea control report mouse.X and mouse.Y was wrong . But the tslib library report the click X and Y was right . When we changed the tp . we use a tp size of 240320 . and running the same application . the mousearea control was right . I think that should we config the dimensions about tp when compiling the Qt runtime library.

      Code :
      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.0

      ApplicationWindow {
      visible: true
      width: 240
      height: 240
      title: qsTr("Hello World")
      flags: Qt.FramelessWindowHint

      SwipeView {
          id: swipeView
          anchors.fill: parent
          currentIndex: 0
      
          Page {
              Rectangle
              {
                  color: "red"
                  anchors.fill: parent
      
                  MouseArea
                  {
                      anchors.fill: parent
                      onClicked: console.log("X:" + mouseX + " , Y:" + mouseY)
                  }
              }
          }
          Page {
              Rectangle
              {
                  color: "yellow"
                  anchors.fill: parent
              }
          }
      

      }

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Consider this passage from Qt documentation of mouseX:

        If the hoverEnabled property is false then these properties will only be valid while a button is pressed, and will remain valid as long as the button is held down even if the mouse is moved outside the area.

        When responding to clicked() signal, you are better off using mouse.x and mouse.y (which the signal sends to the slot), instead of "global" mouseX and mouseY properties.

        (Z(:^

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