Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Send KeyEvent from QWidget to QML element

$
0
0
Hello, I have two windows : one QQuickView and one QGLWidget. The process of key events are made in the root item of the main window QQuickView, so it is made in qml with a javascript function (handler Keys.onPressed). So now I also want to catch keyevents in QGLWidget, it works well with “keyPressEvent(QKeyEvent* event)”, and I want to forward it to my root item in QQuickView. Here is my code : void MyGLWindow::keyPressEvent(QKeyEvent* event) {     QKeyEvent* eventCopy = new QKeyEvent(event->type(), event->key(), event->modifiers());     QApplication::postEvent(quickView->rootObject(), eventCopy); } It does not work, does anyone understand why ?

Viewing all articles
Browse latest Browse all 4972

Trending Articles