Unsolved Invoke onPressed from another function within a qml
-
I am writing a program using qml. and I need to invoke the mouseArea onPressed fucintion within my function in QML. does anyone know how to do it?
My second question is how to change the mouse position (x,y) from within qml?Thanks
-
Hi! @FlacoDanziger said:
I need to invoke the mouseArea onPressed fucintion within my function in QML
import QtQuick 2.6 import QtQuick.Controls 1.5 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") Rectangle { id: myRectangle width: 300 height: 300 anchors.centerIn: contentItem color: "black" MouseArea { id: myMouseArea anchors.fill: parent onPressed: myRectangle.color = "orange" } } Button { anchors.bottom: contentItem.bottom text: "Press" onClicked: { var ma = Qt.MouseEvent myMouseArea.onPressed(ma) } } }
-
@Wieland said:
var ma = Qt.MouseEvent
myMouseArea.onPressed(ma)Thanks this worked