Invoke onPressed from another function within a qml
-
wrote on 9 May 2016, 12:37 last edited by
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
-
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
wrote on 9 May 2016, 12:52 last edited byHi! @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) } } }
-
wrote on 9 May 2016, 15:44 last edited by
@Wieland said:
var ma = Qt.MouseEvent
myMouseArea.onPressed(ma)Thanks this worked
1/3