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 stuck in pressed state
QtWS25 Last Chance

MouseArea stuck in pressed state

Scheduled Pinned Locked Moved Solved QML and Qt Quick
mouseareabugqmltouch
3 Posts 2 Posters 2.5k 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.
  • N Offline
    N Offline
    nx7z
    wrote on 26 Apr 2017, 10:18 last edited by
    #1

    Hi,

    I stumbled on a problem with the MouseArea on a Touchscreen: If you hold the MouseArea pressed while setting the visibility of the Area (or a parent) to false the MouseArea won't work anylonger (even when visible again) and any press or click is ignored, even with the mouse.

    I made an little example, use it like this:

    1. Touch and release the orange Rectangle.
    2. Then quickly touch and hold the touch till the orange Rectangle is no longer visible.
    3. Release.
    4. The Rectangle now will toggle every 3secs visibility.
    5. But even when the "brokenMouseArea" is visible, it won't accept any new clicks or touch events. All clicks of the orange Rect are now handle by the "fallbackMouseArea". Which is wrong.
    import QtQuick 2.5
    import QtQuick.Window 2.0
    
    Window {
        visible: true
        width: 640
        height: 480
    
        MouseArea {
            id: fallbackMouseArea
            anchors.fill: parent
            onPressedChanged: console.log("fallbackMouseArea - pressed: " + pressed );
        }
    
        Rectangle {
            id: rect
            width: 100
            height: 100
            anchors.centerIn: parent
            color: "orange"
            MouseArea {
                id: brokenMouseArea
                anchors.fill: parent
                onClicked: timer.running = !timer.running
                onPressedChanged: console.log("brokenMouseArea - pressed: " + pressed );
            }
        }
    
        Timer {
            id: timer
            interval: 3000
            repeat: true
            onTriggered: rect.visible = !rect.visible
            onRunningChanged: console.log("running: " + running );
        }
    }
    

    Logging results using the Mouse:
    qml: brokenMouseArea - pressed: true
    qml: brokenMouseArea - pressed: false
    qml: running: true
    qml: brokenMouseArea - pressed: true
    qml: brokenMouseArea - pressed: false
    qml: brokenMouseArea - pressed: true
    qml: brokenMouseArea - pressed: false
    qml: running: false

    Note: The MouseArea pressed state is set to false when visibility is changed to false which is correct behaviour.

    Logging results using a Touchmonitor:
    qml: brokenMouseArea - pressed: true
    qml: brokenMouseArea - pressed: false
    qml: running: true
    qml: brokenMouseArea - pressed: true
    qml: fallbackMouseArea - pressed: true
    qml: fallbackMouseArea - pressed: false
    qml: fallbackMouseArea - pressed: true
    qml: fallbackMouseArea - pressed: false
    qml: fallbackMouseArea - pressed: true
    qml: fallbackMouseArea - pressed: false
    qml: fallbackMouseArea - pressed: true
    qml: fallbackMouseArea - pressed: false

    Note: "qml: brokenMouseArea - pressed: false" is missing. The MouseArea is stuck in "pressed = true" and won't go back to pressed = false

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jpnurmi
      wrote on 26 Apr 2017, 17:18 last edited by
      #2

      Are you using Qt 5.8.0? I recall such bug. It was probably fixed by https://codereview.qt-project.org/#/c/186452/ so the fix would be available in Qt 5.9.0. You can already test with the lastest Qt 5.9 beta available in the online installer.

      1 Reply Last reply
      1
      • N Offline
        N Offline
        nx7z
        wrote on 28 Apr 2017, 08:39 last edited by
        #3

        Thanks for your input jpnurmi!

        Yes I'm using 5.8 and 5.9 beta is fixing this issue! Thanks for pointing it out! For some reason I didn't find this bug!

        Best,
        nx

        1 Reply Last reply
        0

        1/3

        26 Apr 2017, 10:18

        • Login

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