Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18656

MouseArea has confusing onMousePositionChanged in addition to onPositionChanged

XMLWordPrintable

    • df5c836fe9753e81cda4a30fa27ce7af5e6f9a5f

      In addition to MouseArea's onPositionChanged, QtCreator's word completion
      also suggests onMousePositionChanged, which apparently does exist but doesn't
      work correctly when one expects onPositionChanged (e.g. it's called even
      though "mouse.accepted = false" is called in onPressed). If it's an internal
      signal it ought to be better hidden, as it is too easy to confuse it with
      onPositionChanged.

      Run the code below. Press down and drag in the window. because "mouse.accepted = false" is called in onPressed, no printout is expected to the console if the onPositionChanged was used correctly. But because the onMousePositionChanged was used "by mistake" the signal is triggered unexpectedly.

      import QtQuick 1.1
      
      Rectangle {
          width: 640
          height: 360
          color: "gray"
      
          MouseArea {
              anchors.fill: parent
              onPressed: mouse.accepted = false
              onMousePositionChanged: print("onMousePositionChanged")
          }
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes