Sunday 15 April 2012

qt - Pass Events Between QML Objects -



qt - Pass Events Between QML Objects -

i have situation pass qml event qml item in middle of initial event handler. e.g.

item { id: item1 keys.onpressed: { // pre-process... passeventtoobject(event, item2); // post-process based on results of event passing... } } textinput { id: item2 // expect key press event handled text input }

what can acheive passeventtoobject?

notes:

i don't have access modify keys.onpressed within item2, it's qml built-in (textinput). the event passing must happen in middle of item1.keys.onpressed

i think useful section "signal signal connect" can find here. basically, each signal has connect method can exploited create signals chain.

if interested forword key events (as in example) consider instead forwardto property:

this property provides way forward key presses, key releases, , keyboard input coming input methods other items. can useful when want 1 item handle keys (e.g. , downwards arrow keys), , item handle other keys (e.g. left , right arrow keys). 1 time item has been forwarded keys accepts event no longer forwarded items later in list.

the documentation provides nice , simple example.

qt qml qevent

No comments:

Post a Comment