Can I generate an event such as KeyPress?

494 views
Skip to first unread message

Charles Hawkins

unread,
May 29, 2015, 8:29:32 AM5/29/15
to go-...@googlegroups.com
First off, a big "Thank You!" to the developers of go-qml.  I'm doing a test case conversion of one of my programs to see if I want to convert the others.  So far, I'm really liking what I see.

Here's my problem.  I'm converting a specialized editor from OCaml/Tk to go-qml.  It has a key-stroke record/playback function that is implemented using TK's "generate event".  Does Qt or go-qml have anything similar?  This isn't a show-stopper, but it would save me a fair amount of work.  Basically, I want to fire a Key event to a TextEdit widget.

David Marceau

unread,
May 30, 2015, 5:20:22 AM5/30/15
to go-...@googlegroups.com
There is no go-qml automation robot/macro-recorder that I'm aware of.
Ubuntu touch has a python test automation tool which works for all qml
apps including go-qml apps, but it doesn't record your actions from your
go-qml ui.

This might be what you want:
http://doc.qt.io/qt-5/qtqml-syntax-signals.html#signal-to-signal-connect
Essentially, you could do whatever the gui is supposed to do, but hook
in a relayer to record events both mouse and keyboard somewhere.
You would need something to load up your event info.
Then you would need something to send/post your event info. If the
signal-to-signal stuff isn't enough, then read about lower level
postevent and sendevent from c++.
QApplication::postEvent( widget, event );
sendEvent();
If you look in go-qml, you might find postevent/sendevent golang api
wrapper calls there along with some usage of them within the api sources
and samples.

Charles Hawkins

unread,
May 30, 2015, 9:41:43 AM5/30/15
to go-...@googlegroups.com
Thanks, David.  sendEvent() is probably what I'm looking for.
Reply all
Reply to author
Forward
0 new messages