MouseArea emitting additional 'pressed' signal



  • I using QML on Linux device with touch screen.
    Sometimes when I pressing a MouseArea it emits another 'pressed' and 'released' signals (In addition to the original events).
    I added log also to the 'clicked' signal and I saw that when the additional 'pressed' and 'released' signals are emitted the 'clicked' signal is not emitted (even though the press and release where both within the MouseArea).
    Can anyone explain why does the additional signals are emitted ?


  • Moderators

    Hi @aabc,
    As the docs says, a click is defined as a press followed by a release, so if you define all the 3 handlers they are surely going to trigger i.e a press followed by release followed by click event.



  • Hi p3c0,

    The problem is that the 2nd 'pressed' and 'released' events are triggered without someone is actually pressing the MouseArea.


  • Moderators

    @aabc Strange. Can you post some code to test ? Which Qt version and OS are you using ?



  • I'm using Qt 5.3.1 on Linux (Freescale i.mx53 with touch device).

    Rectangle
    {
        width: 200
        height: 200
        color: "red"
    
        MouseArea
        {
            anchors.fill: parent
            onPressed: console.log("Pressed")
            onReleased: console.log("Released")
            onClicked: console.log("Clicked")
        }
    }
    

  • Moderators

    @aabc I tested it on android device with Qt 5.4.1 and it works as expected. Order of signal trigger is pressed, released and clicked. No other ghost events.



  • It doesn't happens all the time. The phenomenon reproduce once per ~15 times.
    Another strange issue when it does happen - There are 'pressed' and 'released' events but no 'clicked' event.


  • Moderators

    @aabc Could be a bug in Qt 5.3.1. Can you try with latest one ? Just to confirm. So that you can submit a bug report.



  • @aabc , I checked with Qt 5.4.1 MSVC2012 OpenGL 32bit and it works correctly.
    Tried many times and able to get pressed , released and clicked signals in order.
    You will not get clicked signal in one case ,
    if you do press in Rectangle region (200 * 200 ) and do mouse move outside and perform mouse release.
    then you will get only pressed & released.


  • Moderators

    @RamK Because that is what click is defined. From the docs:

    A click is defined as a press followed by a release, both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and releasing is also considered a click).



  • There sould have been 'clicked' signal:
    I logged the X and Y coordinates of the 'pressed' and the 'released' and they both were within the MouseArea.


Log in to reply
 

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