c++ - QtQuick key press event propagation -
i have qt gui application. main window contains qtquick component placed on using window container:
qquickview * view = new qquickview (); qwidget * container = qwidget::createwindowcontainer (view, this);
i'd handle key press events under whole window. faced problem can't handle key events when focus acquired qtquick component if i've set window parent it.
the documentation such behaviour expected:
qwidget *qwidget::createwindowcontainer(qwindow *window, qwidget *parent = > q_nullptr, qt::windowflags flags = qt::windowflags())
...
window container has number of known limitations:
...
focus handling; possible let window container instance have focus policy , delegate focus window via call qwindow::requestactivate(). however, returning normal focus chain qwindow instance qwindow instance implementation itself. instance, when entering qt quick based window tab focus, quite further tab presses cycle inside qml application. also, whether qwindow::requestactivate() gives window focus, platform dependent.
my question is: there way handle key press event under whole window if focus acquired qtquick component?
minimal , complete example available @ gitlab.
one possible (but ugly) solution is:
- handle key press event in qml;
- notify c++ code qml signal;
- in c++ code generate key press event;
- handle native event , regenerated event in common event filter.
example available @ gitlab.
Comments
Post a Comment