Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Example usage of QWidget::InputMethodEvent
Forum Updated to NodeBB v4.3 + New Features

[Solved] Example usage of QWidget::InputMethodEvent

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 7.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    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 that

    Thanks
    @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();
        }
    

    };@

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zither
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thisisbhaskar
          wrote on last edited by
          #4

          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 ???

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zither
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • T Offline
              T Offline
              thisisbhaskar
              wrote on last edited by
              #6

              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...

              https://qt.gitorious.org/uiemo/uiemo-preview/blobs/master/src/hbplugins/inputmethods/common/hbinputmodehandler.cpp

              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...

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved