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. Return the mouse position to its previous configurable location in QML?
Forum Updated to NodeBB v4.3 + New Features

Return the mouse position to its previous configurable location in QML?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 423 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.
  • S Offline
    S Offline
    Saeed_Nowroozi
    wrote on last edited by
    #1

    I wrote a code that when pressed and hold left bottom hide cruises the mouse, and changes the value of a variable as the mouse changes position. Once the mouse is released, the mouse should appear where it was hidden. I checked all the properties of the MouseArea but it did not work.

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      Post a snippet of your 'working' code for us to see.

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Saeed_Nowroozi
        wrote on last edited by
        #3

        ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")

            id: hhhhh
        
        property int name: 0
        property alias curso: mous.cursorShape
        
        property bool cursorPosActive : false
        property bool shift : false
        
        
        property point cursorPos
        property bool pox_logic: false
        //property bool xxx: false
        property real step_shift: 2
        
        
        
        property point startFlickContentRef: Qt.point(0, 0)
        
        property point startFlickMousePos: Qt.point(mous.mouseX, mous.mouseY)
        property bool flicking: false
        
        
        MouseArea {
            function setText(event)
            {
                var the_key = event.key
                if (the_key === Qt.Key_Shift) return true
                  return false
            }
        Keys.onPressed: shift = setText(event)
            id:mous
            onExited: { cursorPosActive = false }
        
            onPositionChanged: {  // MouseEvent OK
                if(pox_logic === true){
                    console.log(mouse.x + " " + mouse.y);
                                }
                if(shift) console.log((mouse.x * step_shift) + " " + (mouse.y * step_shift));
        
            }
        
            onEntered: {  // here: mouseX/Y OK?
                cursorPos = Qt.point(mouseX, mouseY)
        
                cursorPosActive = true
            }
            onClicked: {  // MouseEvent OK
                cursorPos = Qt.point(mouse.x, mouse.y)
        
            }
            onPressAndHold:
            {
                startFlickContentRef = Qt.point(mous.mouseX, mous.mouseY)
                // console.log(startFlickContentRef.x + " " + startFlickContentRef.y);
                curso = Qt.BlankCursor
                pox_logic= true
                cursorPos = Qt.point(mouse.x, mouse.y)
        
            }
        
            onReleased: {mous.moveCursor()}
        

        // curso = Qt.ArrowCursor
        // pox_logic =false
        // // mouseXChanged() = startFlickContentRef.x
        // // mouse.y = startFlickContentRef.y
        // mous.moveCursor();

        //// mouseX: startFlickContentRef.x

        //// mouseY: startFlickContentRef.y
        // anchors.fill: parent
        // //enabled: false
        // hoverEnabled: true
        // cursorShape:Qt.ArrowCursor
        // }//MouseArea
        // MouseArea {
        // width:startFlickContentRef.y; height: startFlickContentRef.x
        // // onClicked: console.log("irregular area clicked")
        }
        }

        1 Reply Last reply
        0
        • rrlopezR Offline
          rrlopezR Offline
          rrlopez
          wrote on last edited by
          #4

          Hello @Saeed_Nowroozi. I don't really know if what you want to do is available in QML. However, there is something in qt called "event filters": https://doc.qt.io/archives/4.6/eventsandfilters.html. You can create an event filter as shown in the link to filter mouse events and either let the application handle them or not. In your case, you may want to create some sort of variable that gets changed when you hide the mouse and stop all mouse navigation related events. If you have any other questions please let me know and I'll try my best to help you.

          Lic-Ing. Rodrigo Lopez Gonzalez
          Embedded Software Engineer
          RidgeRun Engineering Ltd.
          www.ridgerun.com
          Email: rodrigo.lopez@ridgerun.com

          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