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. MouseArea Control Click Position Problem

MouseArea Control Click Position Problem

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 700 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.
  • M Offline
    M Offline
    Mr .Wu
    wrote on last edited by
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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
      0

      • Login

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