Need an example for proecessing unicode input and input method



  • Hi,

    I want to create a customize text editor control which will derive from QWidget or QWindow, if just support English, I can deal the keyboard events, but I need to support Chinese and other characters that will need a input method, but I don't know how to support input methods.
    I have read an simple example for Win32/MFC, and I remembered that it just need:

    Create an caret(how to creat a caret within Qt? I have not found a API for this purpose.) and show it, set the caret's position by calling SetCaretPos(...), and the input method's compositing window will appear below the caret's position(How to control this position within Qt? This is important, if we can't control the compositing window's position, then it will appear at the left corner of the QWindow QWidget or Desktop).

    Response the WM_CHAR message, this will get the characters from keyboard or input method(How to get these characters within Qt?).

    Draw the text, and set the caret's position again.

    I have read the documents for QInputMethodEvent and QInputMethodQueryEvent, but got nothing. And I have tried to read the QPlainTextEdit's source code, but I found that it's so complex, there's so many abstract layers that I can't understand immediately, I realy need a simple one.

    Thanks.



  • By response the KeyPress event, I can get the unicode characters now, but I still don't know how to create a caret and set it's position.
    May be I can draw a caret myself, and use a timer to control it's display, but, how to control the input methods' compositing window's position?



  • The post is very good.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.