code like this:
first set the property:
key_backspace-> setProperty ("buttonValue", QVariant (QChar (Qt :: key_BackSpace)));
then set mapper:
signalMapper.setMapping (key_backspace, key_backspace);
connect (key_backspace, SIGNAL (clicked ()), & signalMapper, SLOT (map ( ) ) ) ;
then connect signals and slots
connect (inputPanel, SIGNAL (characterGenerated (QChar)), SLOT (sendCharacter (QChar)));
then the slot function , this is the Qt inputpanel source path example/qt4.7/tools/inputpanel
void MyInputPanelContext :: sendCharacter (QChar character)
{
QPointer
if (! w)
return;
QKeyEvent keyPress (QEvent :: KeyPress, character.unicode (), Qt :: NoModifier, QString (character));
PRINT2 ("keypress =% d \ n", keyPress.key ());
QApplication :: sendEvent (w, & keyPress);
if (! w)
return;
QKeyEvent keyRelease (QEvent :: KeyPress, character.unicode (), Qt :: NoModifier, QString ());
PRINT2 ("keyrelease =% d \ n", keyRelease.key ());
QApplication :: sendEvent (w, & keyRelease);
}
backspace key code is 0x01000003, used to transmit QChar seems a little problem, but do not, there are other ways?
Later, I found a more stupid way to solve this problem is in the above then add this function for the special treatment of the backspace key
if (character.toAscii () == 3) / / backspace
{
QWSServer :: sendKeyEvent (0x01000003, Qt :: Key_Backspace, Qt :: NoModifier, true, false);
}
This also solved, but this method is not good, consult experts doors, there is no better way to solve this problem.
------ Solution ------------------------------------ --------
Key_Backspace is 0x01000003, need 32bit to store , use unsigned int can
------ eference ----------- ----------------------------
QWSServer Will you use this function in which the first document , you have to find other good way ah
------ eference ------------------------------------- -
# include
------ eference ---------------------------- -----------
currently have not found a good way
------ eference ------------------- --------------------
ask , why do I follow your method will appear
undefined reference to `_imp___ZN9QWSServer12sendKeyEventEii6QFlagsIN2Qt16KeyboardModifierEEbb '
such a mistake?
hope can get your reply !
------ eference --------------------------------------- < br> I have encountered this situation upstairs , I do not know what causes it ?
------ eference --------------------------------------- < br> another one of my colleagues have encountered this problem , he and I discussed for a long time , his own works and header files gave him go unmet.
Later, I thought , I use the embedded embeded qt. QWS server is specifically written for embedded QT classes , in the non- embedded platforms may not be used.
------ eference --------------------------------------- < br> that means using arm compiler tool chain can do ? I'll try
------ eference ------------------------------------ ---
examination results of how ?
------ eference --------------------------------------- < br> The QChar class provides a 16-bit Unicode character.
The inputpannel inside characterGenerated (QChar), instead characterGenerated (unsigned int), all the way to be rid of
now tried Key_Backspace can issue to , but will be issued two times , is addressing
------ eference -------------------- -------------------
http://stackoverflow.com/questions/17621741/implementing-backspace-and-enter-keys-on-a-qt- virtual-keyboard
没有评论:
发表评论