Do postEvent to QtQuick2ApplicationViewer and be received automatically by qml
-
Can we do postEvent to QtQuick2ApplicationViewer and be received automatically by qml?
@
QGuiApplication::postEvent(qApp->allWindows().at(0), new QMouseEvent( QEvent::MouseButtonPress, QPointF(10,10), Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier));
// I hope I can receive the event and being catched by qml layer (since I sent an event -- mouse click events to the window)
import QtQuick 2.0
Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
console.log("hurrah")
}
}
}@
Thanks!