MouseArea Control Click Position Problem



  • 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
            }
        }
    

    }


  • Moderators

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.