Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

mouse area pin mode



  • import QtQuick 2.12
    import QtQuick.Window 2.12
    
    Window {
    	width: 640
    	height: 480
    	visible: true
    	title: qsTr("Hello World")
    
    	Rectangle{
    		color: "red"
    
    		width: 300
    		height: 300
    
    		x:10
    		y:10
    
    		MouseArea{
    			anchors.fill: parent
    			hoverEnabled: true
    			
    
    
    			onExited: {
    				console.log("exit red")
    			}
    			onEntered: {
    				console.log("enter red")
    			}
    			onMouseXChanged: {
    
    				console.log("x mouse red"+mouseX)
    			}
    			onMouseYChanged: {
    				console.log("y mouse red"+mouseY)
    
    			}
    		}
    
    	}
    
    	Rectangle{
    		color: "green"
    
    		width: 100
    		height: 100
    
    		x:130
    		y:10
    
    		MouseArea{
    			anchors.fill: parent
    			hoverEnabled: true
    
    
    
    			onExited: {
    				console.log("exit green")
    			}
    			onEntered: {
    				console.log("enter green")
    			}
    
    		}
    	}
    
    }
    

    In this part, I have two rectangles and inside each rectangle, there is a mouse area
    In this part, I want to do the pin mode with the Aria mouse, but the problem is that when the next rectangle, which is located on the lower rectangle, is removed from the Aria mouse, the window can not be opened at the top.

    Exactly so that you can use the mouse's position in mouse area when there is a button on mouse area, for example, and that the mouse area is on the button does not allow us to exit the mouse area.

    Thanks for the support



  • I am not getting your problem. Are you looking for something like this to print x and y when there is a position change.
    onPositionChanged: {
    console.log("x:"+ mouse.x+ " y:"+mouse.y)
    }


Log in to reply