[Solved] Example usage of QWidget::InputMethodEvent
-
Dear all,
I read the documentation about QWidget::InputMethodEvent Usage but I don't understand.
Plz help me or show me where can I get some examples about that.I got one example but it doesn't work
Plz show me what's wrong with thatThanks
@class InputWidget : public QWidget
{
public:
InputWidget( QWidget* parent =0 )
: QWidget( parent )
{
setAttribute( Qt::WA_InputMethodEnabled);
setAttribute( Qt::WA_KeyCompression );
}~InputWidget() {}
protected:
void inputMethodEvent( QInputMethodEvent* m )
{
qDebug() << "inputMethodEvent";
}QVariant inputMethodQuery( Qt::InputMethodQuery p ) const { qDebug() << "inputMethodQuery"; return QVariant(); }
};@
-
This is basically reimplemented for TextEditors or any widgets which accepts character string inputs. To get this method called, somebody has to post a QInputMethodEvent event to this widget with
bool QCoreApplication::sendEvent ( QObject * receiver, QEvent * event );
In the case of QLineEdit, QTextEdit the default QInputContext installed on QApplication sends them.
If you have your own QInputContext installed on QApplication or QWidget ( setInputContext), you send it from that input context.
Look at http://doc.qt.nokia.com/latest/qinputmethodevent.html for more information.
-
Thanks for your advice
I try with QInputMethodEvent but I don't know how to use these events
There is no examples on internet about QInputMethodEvent. I make myTextEdit widget as child class of QTextEdit & make attribute Qt::WA_InputMethodEnabled.
But I don't know how to start the process "Starting to Compose" & how to catch KeyPressEvent..
Plz help again..Thanks
-
It may not be that simple to write a usable widget that can process all input method events. Just curious why are you trying to do this?? what is the use case ???
-
It's related with "that Topic":http://developer.qt.nokia.com/forums/viewthread/7230
I would like to make such Qt input method & don't know where can I catch KeyPress to Input Widget..
Thanks
-
The below link is git repo for "Mobile Extensions" Symbian 4 project. It has got whole framework of QGraphicsWidget based widgets developed for mobile phones. Sadly its scrapped.
https://qt.gitorious.org/uiemo/uiemo-preview/trees/master
One place where you can find this QInputMethodEvent posed is...
The software keypads code is at https://qt.gitorious.org/uiemo/uiemo-preview/trees/master/src/hbinput/inputwidgets
and actual inputmethods ( QInputContext derived classes) is at https://qt.gitorious.org/uiemo/uiemo-preview/trees/master/src/hbplugins/inputmethods
And HbLineEdit code which receives QInputMethodEvent is at https://qt.gitorious.org/uiemo/uiemo-preview/trees/master/src/hbwidgets/editors
And https://qt.gitorious.org/uiemo/uiemo-preview/blobs/master/src/hbwidgets/editors/hbabstractedit.cpp handles some of inputMethodEvent events at line 244.
And obviously one best place to study in Qt Source code it self...