MouseArea with wrong anchors



  • Hi,

    i run my App on an Embedded Linux and already looked at what /dev/input/event0 gave me but i guess the Bug is in QML. This Code:

        MouseArea
        {
          id: ic
          anchors.fill: parent
          onReleased:
          {
            console.log("X: " + mouseX  + " Y: "+ mouseY)
            console.log("Width: " + width  + " Height: "+ height)
          }
        }
    

    will create this Output when i first touch where I expect the MouseArea and then touch about 80 times ... well somwhere next to the expected MouseArea. X and Y seems to be ok. Is this even possible?

    qml: X: 137.8694418164617 Y: 27.737113559373768
    qml: Width: 204 height: 132\n"
    qml: X: 561.9678334910124 Y: 58.0734885708182
    qml: Width: 204 Height: 132\n"
    

    Im using Qt5.6.0
    Regards



  • This post is deleted!


  • Hi,

    In fact it is not possible :p
    Could we see MouseAreas parent code ?

    La


  • Moderators

    Hi! If you press inside the mouse area, hold and then release outside the mouse area, you get coordinates outside the mouse area. Try the follow, it should only report coordinates from the inside:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.3
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        color: "lightgrey"
        Rectangle {
            color: ma.containsPress ? "red" : "grey"
            anchors.centerIn: parent
            width: 200
            height: 60
            border.width: 2
            MouseArea {
                id: ma
                anchors.fill: parent
                hoverEnabled: true
                onReleased: {
                    if (!ma.containsMouse) {
                        console.log("released outside mouseArea")
                    } else {
                        console.log("" + mouseX + ", " + mouseY)
                    }
                }
            }
        }
    }
    


  • I tried

        MouseArea
        {
          id: ic
          anchors.fill: parent
    
          onPressed:
          {
            console.log("onPressedX: " + mouseX  + "Y: "+ mouseY)
            console.log("onPressedWidth: " + width  + "Height: "+ height)
          }
    
          onReleased:
          {
            if(ic.containsMouse)
            {
              console.log("contain")
            }
            else
            {
              console.log("noContain")
            }
            console.log("OnReleasedX: " + mouseX  + "Y: "+ mouseY)
            console.log("onReleasedWidth: " + width  + "Height: "+ height)
          }
        }
    

    Output

    qml: onPressedX: 0Y: 59.19705801568654
    qml: onPressedWidth: 204Height: 132
    qml: noContain
    qml: OnReleasedX: 579.20151371807Y: 65.18942838831754
    qml: onReleasedWidth: 204Height: 132
    

    So i guess the pressed on 0Y is wrong here. Can i debug mouseevents that come from tslib (ts_print output was ok) through my Qt application anyhow globally?



  • I overloaded

        void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE{
          QWindow::mousePressEvent(event);
          qDebug() << Q_FUNC_INFO << event->pos();
        }
    

    and the output sometimes had a zero in y or x coordinates so my first guess is an error in the touch driver or underneath.


Log in to reply
 

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