PDA

View Full Version : Redirect key strokes



iPick12
11th September 2012, 17:49
Hello
I'm developing a small CAD and I want to copy an AutoCAD feature.
More specifically, when the user types something in the drawing area,
I want it to be redirected to a certain QTextEdit.
I thought about calling onKeyPress() and onKeyRelease() functions but I'm not
sure if that's enough and it won't cause any nasty bugs. What do you think?

amleto
11th September 2012, 17:55
erm, maybe use qwidget.html#keyPressEvent (and release) and qcoreapplication.html#postEvent to re-direct the event.

maybe this can be done quicker with event filter, otherwise you could knock up a pretty inefficient signal/slot mechanism whereby the drawing area just emits every char that the user types in it, and you connect it to the text edit for appending.