Raise key pressed event when button is clicked?
Hi,
I'm developing an embedded Qt application where the only input method will be using the touchscreen and have made a virtual keyboard mapped with QSignalMapper. When a user presses (touches, clicks) a button on the virtual keyboard I would like the same behaviour as if a real keyboard was used. How do I do that? I figure it should be something like:
Code:
void Widget::keySelected (const QString& key) {
int i = key.at(0).toAscii();
}
But that doesn't work.
The following code:
Code:
void Widget::keySelected (const QString& key) {
qDebug() << key;
}
gives the output of the keyvalue, e.g. "A" if the A-button is pressed.
Would be greatful if someone has a hint here :)
Re: Raise key pressed event when button is clicked?
i think this thread will be useful to u .. but may solve your problem .. try this
http://www.qtcentre.org/forum/f-newb...ner-20799.html
Re: Raise key pressed event when button is clicked?
I'm afraid that didn't help. The problem isn't catching the events, but to raise new ones.
Re: Raise key pressed event when button is clicked?
You can use QCoreApplication::sendEvent()/QCoreApplication::notify()/QCoreApplication::postEvent() for that. Theoretical, because once I tried to send mous event in a graphics scene I failed, but the case was a bit of complexer.
Re: Raise key pressed event when button is clicked?
Quote:
Originally Posted by
Lykurg
Thanks! That works fine. Only problem is that it overwrites existing text and not adding the new letter. Why is that?
Just to clarify, do I really need to write a eventhandler for each widget that are going to use the virtual keyboard? Isn't there any way to just simulate a physical keyboard and use Qt:s generic inputeventhandlers?
Re: Raise key pressed event when button is clicked?
Re: Raise key pressed event when button is clicked?
download the QtExtended source code.
go to
src/plugins/inputmethods/keyboard
there they have implemented a virtual keyboard. this may help
Re: Raise key pressed event when button is clicked?
Quote:
Originally Posted by
MrDeath
download the QtExtended source code.
go to
src/plugins/inputmethods/keyboard
there they have implemented a virtual keyboard. this may help
They use the QWSServer to send keyevents which obviously doesn't work on the desktop. It would have been convienient to be able to use some sort of generic Qt-feature for future reuse but I'll guess I have to go with QWSServer for now... thanks.