Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. mousearea
    Log in to post

    • SOLVED Simultaneous mousearea drag event
      QML and Qt Quick • qml qtquick mousearea drag multipointtouch • • DeltaSim  

      2
      0
      Votes
      2
      Posts
      40
      Views

      I finally succeed to create this using 2 MultiPointTouchArea but I had to write drag function on touchUpdated event. Here is my code for one drag area: import QtQuick 2.0 Item{ id: joystick width: 100 height: 500 Rectangle{ id: joystickPad height: 50 width: 100 MultiPointTouchArea{ property var offset: null anchors.fill:parent minimumTouchPoints: 1 maximumTouchPoints: 1 function dragMove(point) { if (point) { var position = joystick.mapFromItem(joystickPad, point.x, point.y); /* Change y axis */ if((position.y - offset.y) < 0) { /* Do not go on top of drag area */ joystickPad.y = 0; } else { if((position.y - offset.y) > (joystick.height-joystickPad.height)) { /* Do not go below of drag area */ joystickPad.y = (joystick.height-joystickPad.height); } else { joystickPad.y = position.y - offset.y; } } } } onPressed: { var point = touchPoints[0]; offset = Qt.point(point.x, point.y); } onTouchUpdated: { var point = touchPoints[0]; dragMove(point); } onReleased: { //Reset position joystickPad.x = (joystick.width/2 - joystickPad.width/2) joystickPad.y = (joystick.height/2 - joystickPad.height/2) } } } }
    • SOLVED MouseArea stuck in pressed state
      QML and Qt Quick • qml bug mousearea touch • • nx7z  

      3
      0
      Votes
      3
      Posts
      1547
      Views

      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
    • UNSOLVED MouseArea with forwarded events does not receive release event
      QML and Qt Quick • mousearea mouse event mousepressevent event handling • • hvoigt  

      4
      0
      Votes
      4
      Posts
      1104
      Views

      @JLimbocker Tried your code but unfortunately it does not exactly what I want. It is selecting from the beginning instead of from where I was clicking when dragging. Problem with passing the mouse event through to the TextField is that when I do that using mouse.accepted = false. The other handler like onRelease: are not called on the MouseArea anymore which destroys my handling there. The selectAll() could be switched off when something is already selected but I do not know why that TextField's selection is starting from the beginning... Anyone knows how to forward the mouse events to an underlying element but still have the complete handling in the MouseArea available? That would solve my question.
    • UNSOLVED MouseArea inside MapQuickItem not clickable?
      General and Desktop • qtlocation mousearea clicked mapquickitem • • Nandakishore  

      2
      0
      Votes
      2
      Posts
      1160
      Views

      I just stumbled accros the same odd behavior with Qt 5.7.1. However, the strange thing is, that it seems to be only a problem on android (on windows it's fine). Does anybody know if that's a (already reported) bug?
    • UNSOLVED Mouse PressAndHold
      QML and Qt Quick • mousearea buttons • • msinger  

      2
      0
      Votes
      2
      Posts
      697
      Views

      In my understanding this is exact what onClicked does. From the online documentation: "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)." MouseArea { anchors.fill: parent onClicked: console.log("released") onPressed: console.log("pressed") }
    • UNSOLVED MouseArea blocks 'Custom Scene Graph Item's mouse events
      General and Desktop • qtquick mousearea qquickitem scene graph • • kafanti  

      2
      0
      Votes
      2
      Posts
      1241
      Views

      @kafanti If MouseArea handles mouse event it doesn't pass event to its parent. You need: onPressed: { mouse.accepted = false; }
    • UNSOLVED "ReferenceError: mouse is not defined" in MouseArea
      QML and Qt Quick • mouse mousearea • • qwasder85  

      4
      0
      Votes
      4
      Posts
      2449
      Views

      You're welcome ! Since the mystery is gone, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)
    • UNSOLVED How do I emit signal while clicking TableViewColumn?
      QML and Qt Quick • delegate mousearea tableviewcolumn • • Mira13  

      1
      0
      Votes
      1
      Posts
      493
      Views

      No one has replied

    • onWheel not working in Flickable
      General and Desktop • qml flickable mousearea wheel onwheel • • ajvanho6  

      3
      0
      Votes
      3
      Posts
      1836
      Views

      Hello @p3c0 thank you for helping. Unfortunately i did try as you suggested but no luck so far. Mouse wheel is not responding it just wok when i press and drag Don't know what could be the issue. I must check other files of my app maybe something is interfering with this file.
    • QML MouseArea.drag with any button but left button
      QML and Qt Quick • drag and drop mousearea • • dzimiwine  

      2
      0
      Votes
      2
      Posts
      774
      Views

      @dzimiwine Did you try acceptedButtons ? acceptedButtons: Qt.MiddleButton : Qt.RightButton
    • Get mouse position relative to an item.
      QML and Qt Quick • mousearea • • ealione  

      1
      0
      Votes
      1
      Posts
      374
      Views

      No one has replied

    • SOLVED Problem with MouseArea in delegate
      QML and Qt Quick • mousearea • • nnnnn  

      14
      0
      Votes
      14
      Posts
      4598
      Views

      @nnnnn Hmm. I overlooked your onEntered requirement. It doesnot work in my example. The problem is that once you set mouse.accepted=false the release event is not trapped.
    • QML mousearea not working if QQmlApplication in different class
      QML and Qt Quick • qml c++ mousearea qqmlapplication initialize • • AQTStudent  

      3
      0
      Votes
      3
      Posts
      1147
      Views

      I still had to remove the QWidget.. it's useless this way. My error was that I can't have a QWidget class without a QQmlApplicationEngine.
    • Nested MultiPointTouchArea and MouseArea: grab and cancel
      QML and Qt Quick • mousearea multipointtouch • • qvirol  

      1
      0
      Votes
      1
      Posts
      1081
      Views

      No one has replied

    • MouseArea on GridView delegate - onExit doesn't fire if GridView dragged and released outside
      QML and Qt Quick • flickable gridview mousearea • • pholz  

      2
      0
      Votes
      2
      Posts
      712
      Views

      This problem occurs in qt 5.4 under linux. I just checked, and it doesn't occur under 5.3 - there, onExit is correctly triggered even on drag-release outside the GridView.
    • How to implement multiple actions on onClicked [SOLVED]
      QML and Qt Quick • qml signal mousearea • • sosun  

      5
      0
      Votes
      5
      Posts
      2346
      Views

      @mcosta Actually, my problem is solved. Thanks to @t3685 for the solution. I've just forgot to mark it as SOLVED. Anyway, thanks ;)
    • [SOLVED] How do I get the mouse position in a flickable after flicking?
      QML and Qt Quick • flickable mousearea • • momo  

      5
      0
      Votes
      5
      Posts
      3266
      Views

      @nedo99: A big thanks for the tip! That in fact solved my problem, but maybe not in the way you might have thought! I finally got it to work this way: MouseArea { id: myMouseArea property point cursorPos property bool cursorPosActive : false // new code to handle flicking property point startFlickContentRef: Qt.point(0, 0) property point startFlickMousePos: Qt.point(mouseX, mouseY) property bool flicking: false function setStartFlickMousePos(x,y) { // "prepare" for flicking whenever we have a legitimate mouse pos... if (!flicking) // ...but are not actually flicking! startFlickMousePos = Qt.point(x,y) } function startFlick(refPt) { // Note: startFlick() might be called multiple times before endFlick() is called... if (!flicking) { // ...so this is an important check! startFlickContentRef = refPt flicking = true } } function endFlick(refPt) { if (flicking) { var diffX = refPt.x - startFlickContentRef.x var diffY = refPt.y - startFlickContentRef.y statBar.cursorPos = Qt.point(startFlickMousePos.x + diffX, startFlickMousePos.y + diffY) flicking = false } } anchors.fill: parent hoverEnabled: true onClicked: { // MouseEvent OK cursorPos = Qt.point(mouse.x, mouse.y) setStartFlickMousePos(mouse.x, mouse.y) } onEntered: { // here: mouseX/Y OK? cursorPos = Qt.point(mouseX, mouseY) setStartFlickMousePos(mouseX, mouseY) cursorPosActive = true } onExited: { cursorPosActive = false } onPositionChanged: { // MouseEvent OK cursorPos = Qt.point(mouse.x, mouse.y) setStartFlickMousePos(mouse.x, mouse.y) } onWheel: { // WheelEvent OK cursorPos = Qt.point(wheel.x, wheel.y) setStartFlickMousePos(wheel.x, wheel.y) wheel.accepted = false; // pass to Flickable } } Then I added the following code to my Flickable: onFlickStarted: { myMouseArea.startFlick(Qt.point(contentX, contentY)) } onFlickEnded: { myMouseArea.endFlick(Qt.point(contentX, contentY)) } Note that it turned out to be important to use onFlickStarted/Ended instead of onMovementStarted/Ended. Also it's important to update the startFlickMousePos at every opportunity, because at the point where I normally would want to set it (in startFlick()), I might not have a valid mouseX and mouseY (that was the reason for this post in the first place!). Again thanks! Together we are strong!
    • Zoom at Mouse position
      General and Desktop • qt5.4 image flickable mousearea • • shedo  

      8
      1
      Votes
      8
      Posts
      5408
      Views

      @shedo Hmm. Well then try to use the only relevant code from the blog post into your original code. The code of interest would be the one in onWheel handler and the properties it updates.
    • MouseArea moves under cursor position
      QML and Qt Quick • listview mousearea moving containsmouse • • maxsivkov  

      4
      0
      Votes
      4
      Posts
      1593
      Views

      @maxsivkov Scenario is to have several elements (images with attached mouseareas (to change image source when mouse is inside the image) and also show hints (tooltips) for listview's item. So its better no to do it when the ListView scrolls and only when user hovers mouse over that particular Item To show tooltip my idea was to sit on a onPositionChanged event and restart timer, stop it in onExited event. I think better to use onEntered and onExited. Using onPositionChanged will continuously restart it as mouse moves. Also hide it after a particular timeout instead of only in onExited.