[Qt-qml] How to simulate mouse event
kevin.wangbing at nokia.com
kevin.wangbing at nokia.com
Mon Dec 13 10:46:23 CET 2010
Hi,
I'm a freshman on qml plug-in development.
I want to simulate key and mouse events for testing my qml script automatically.
Now, I can simulate the key event successfully by "item->scene()->sendEvent(item, &keyEvent);"
But it cannot work when I call "item->scene()->sendEvent(item, &mouseEvent);" to simulate mouse event.
I've tried another way "QApplication::sendEvent(view, &mouseEvent);", but it still cannot work.
The return value is always false.
My qml script is follow, it can output log when I click actual mouse key.
Rectangle {
id: container
......
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
mouse.accepted = true;
console.log("Mouse Clicked! key: " + mouse.button + " | keys: " + mouse.buttons);
}
}
Do you have any suggestion?
Best Regards,
Kevin Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101213/57879f01/attachment.html
More information about the Qt-qml
mailing list