Qt 6.11 is out! See what's new in the release
blog
How to pass variables between Rectangles?
QML and Qt Quick
5
Posts
3
Posters
3.3k
Views
1
Watching
-
How do I pass a variable from rectangle bottom to rectangle left. For e.g. the code below, I like to pass the bottomMouseY variable of rectangle bottom to rectangle left
Is it related to signals and slots? But I can't find any info about signals and slots for Qt quick
@
Rectangle {
id: bottomMouseArea { id: bottomMouseAreaBorderTop hoverEnabled: true property int bottomMouseY onPressed: { bottomMouseY = mouseY } onPositionChanged: { // pass bottomMouseY to rectagle left } }}
Rectangle {
id: left}
@ -
Do you mean next:
@Rectangle {
id: left
property alias bottomMouseY1 : bottomMouseAreaBorderTop.bottomMouseY
}@ -
- Declare a property on bottom, mouseY, say
- In the onPressed: signal handler, set the bottom.mouseY property
- In left, declare a property, bottomMouseY, say and bind it to bottom.mouseY
Something like this (not tested):
@
Rectangle {
id: bottom
property int mouseY: -1MouseArea { id: bottomMouseAreaBorderTop hoverEnabled: true onPressed: { bottom.mouseY = mouse.y } onPositionChanged: { bottom.mouseY = mouse.y } }}
Rectangle {
id: left
bottomMouseY: bottom.mouseY
}
@