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 pressedButtons

MouseArea pressedButtons

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 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.
  • G Offline
    G Offline
    giovannie
    wrote on last edited by
    #1

    Hello.

    @import QtQuick 1.1

    Text {
    text: mouseArea.pressed

    MouseArea {
    id: mouseArea
    anchors.fill: parent
    }
    }@

    First I press left mouse button and I see true.
    Then I press right mouse button still holding left button and I see true.
    Then I release right mouse button still holding left button and I see false.

    Anybody knows why?

    It is Qt 4.8.2 QtQuick 1.1 on windows with mingw.

    Using pressedButtons property also give strange results with multiple buttons pressed.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raaghuu
      wrote on last edited by
      #2

      it seems that both mouse buttons pressed simultaneously are taken to be another button(because pressedButtons consists of bitwise combination of buttons)if considered together... right and left pressed together amount to a value of '3'... if you want to check if a button is pressed or not, you should use something like:
      @
      if(pressedButtons & Qt.LeftButton)
      //... code here
      @

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bomb3rman
        wrote on last edited by
        #3

        Well the problem is, that you get a release event for the right mouse button, but no pressed event. Instead of the pressed event there is a context menu event.
        What happens is, the left button is pressed, then you press the right button and release it again. The release of the right button sets the internal state to not pressed.
        I think this can be considered as bug...

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          I agree that sounds like a bug -- could you add a new bug via http://bugreports.qt-project.org please?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giovannie
            wrote on last edited by
            #5

            pressedButtons & Qt.LeftButton don't work too but in a different way.
            It stay true after releasing right mouse button but then releasing left button it is not reset.

            Bugreport here https://bugreports.qt-project.org/browse/QTBUG-26458

            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