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 with wrong anchors
Qt 6.11 is out! See what's new in the release blog

MouseArea with wrong anchors

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    louis
    wrote on last edited by louis
    #1

    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

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        Hi,

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

        La

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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)
                          }
                      }
                  }
              }
          }
          
          1 Reply Last reply
          0
          • L Offline
            L Offline
            louis
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • L Offline
              L Offline
              louis
              wrote on last edited by
              #6

              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.

              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