Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QWSInputMethod Class

TheQWSInputMethod class provides international input methods in Qt for Embedded Linux.More...

Header:#include <QWSInputMethod>
Inherits:QObject

This class is under development and is subject to change.

Public Types

enumUpdateType { Update, FocusIn, FocusOut, Reset, Destroyed }

Public Functions

QWSInputMethod()
virtual~QWSInputMethod()
virtual boolfilter(int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat)
virtual boolfilter(const QPoint & position, int state, int wheel)
virtual voidmouseHandler(int offset, int state)
virtual voidqueryResponse(int property, const QVariant & result)
virtual voidreset()
virtual voidupdateHandler(int type)
  • 29 public functions inherited fromQObject

Protected Functions

uintinputResolutionShift() const
voidsendCommitString(const QString & commitString, int replaceFromPosition = 0, int replaceLength = 0)
voidsendEvent(const QInputMethodEvent * event)
voidsendMouseEvent(const QPoint & position, int state, int wheel)
voidsendPreeditString(const QString & preeditString, int cursorPosition, int selectionLength = 0)
voidsendQuery(int property)
uintsetInputResolution(bool isHigh)
  • 8 protected functions inherited fromQObject

Additional Inherited Members

  • 1 property inherited fromQObject
  • 1 public slot inherited fromQObject
  • 1 signal inherited fromQObject
  • 7 static public members inherited fromQObject

Detailed Description

TheQWSInputMethod class provides international input methods in Qt for Embedded Linux.

Note that this class is only available inQt for Embedded Linux.

AQt for Embedded Linux application requires a server application to be running, or to be the server application itself. All system generated events, including keyboard and mouse events, are passed to the server application which then propagates the event to the appropriate client.

An input method consists of a filter and optionally a graphical interface, and is used to filter input events between the server and the client application.

Creating Custom Input Methods

To implement a custom input method, derive from theQWSInputMethod class, and use the server'ssetCurrentInputMethod() function to install it.

When subclassingQWSInputMethod, you can reimplement thefilter() functions to handle input from both physical and virtual keyboards as well as mouse devices. Note that the default implementations do nothing. Use thesetInputResolution() function to control the number of bits shifted when filtering mouse input, i.e., when going from pointer resolution to screen resolution (the current resolution can be retrieved using theinputResolutionShift() function).

Reimplement thereset() function to restore the state of the input method. Note that the default implementation calls thesendEvent() function with empty preedit and commit strings if the input method is in compose mode (i.e., if the input method is actively composing a preedit string).

To receive replies to an input method query (sent using thesendQuery() function), you must reimplement thequeryResponse() function, while themouseHandler() function must be reimplemented if you want to handle mouse events within the preedit text. Reimplement theupdateHandler() function to handle update events including resets and focus changes. TheUpdateType enum describes the various types of update events recognized by the input method.

Using Input Methods

In addition to thefilter(),reset(),queryResponse(),mouseHandler() andupdateHandler() function mentioned in the previous section, theQWSInputMethod provides several other functions helping the window system to manage the installed input methods.

ThesendEvent() function sends the given event to the focus widget, while thesendPreeditString() function sends the given preedit text (encapsulated by an event).QWSInputMethod also provides thesendCommitString() convenience function which sends an event encapsulating the given commit string to the current focus widget, and thesendMouseEvent() function which sends the given mouse event.

Finally, theQWSInputMethod class provides thesendQuery() function for sending input method queries. This function encapsulates the event with aQWSEvent instance of theIMQuery type.

See alsoQWSServer andQt for Embedded Linux Architecture.

Member Type Documentation

enum QWSInputMethod::UpdateType

This enum describes the various types of update events recognized by the input method.

ConstantValueDescription
QWSInputMethod::Update0The input widget is updated in some way; usesendQuery() withQt::ImMicroFocus as an argument for more information.
QWSInputMethod::FocusIn1A new input widget receives focus.
QWSInputMethod::FocusOut2The input widget loses focus.
QWSInputMethod::Reset3The input method should be reset.
QWSInputMethod::Destroyed4The input widget is destroyed.

See alsoupdateHandler().

Member Function Documentation

QWSInputMethod::QWSInputMethod()

Constructs a new input method.

Use theQWSServer::setCurrentInputMethod() function to install it.

[virtual]QWSInputMethod::~QWSInputMethod()

Destroys this input method, uninstalling it if it is installed.

[virtual]bool QWSInputMethod::filter(int unicode,int keycode,int modifiers,bool isPress,bool autoRepeat)

Filters the key input identified by the givenunicode,keycode,modifiers,isPress andautoRepeat parameters.

Note that the default implementation does nothing; reimplement this function to handle input from both physical and virtual devices.

Thekeycode is aQt::Key value, and themodifiers is an OR combination ofQt::KeyboardModifiers. TheisPress parameter is telling whether the input is a key press or key release, and theautoRepeat parameter determines whether the input is autorepeated ( i.e., in which case theQWSKeyboardHandler::beginAutoRepeat() function has been called).

To block the event from further processing, return true when reimplementing this function; the default implementation returns false.

See alsosetInputResolution() andinputResolutionShift().

[virtual]bool QWSInputMethod::filter(constQPoint & position,int state,int wheel)

This is an overloaded function.

Filters the mouse input identified by the givenposition,state, andwheel parameters.

[protected]uint QWSInputMethod::inputResolutionShift() const

Returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input.

See alsosetInputResolution() andfilter().

[virtual]void QWSInputMethod::mouseHandler(int offset,int state)

Handles mouse events within the preedit text.

Note that the default implementation resets the input method on all mouse presses; reimplement this function to alter this behavior.

Theoffset parameter specifies the position of the mouse event within the string, andstate specifies the type of the mouse event as described by theQWSServer::IMMouse enum. Ifstate is less than 0, the mouse event is inside the associated widget, but outside the preedit text. When clicking in a different widget, thestate isQWSServer::MouseOutside.

See alsosendPreeditString() andreset().

[virtual]void QWSInputMethod::queryResponse(int property, constQVariant & result)

Receive replies to an input method query.

Note that the default implementation does nothing; reimplement this function to receive such replies.

Internally, an input method query is passed encapsulated by anIMQuery event generated by thesendQuery() function. The queried property and the result is passed in theproperty andresult parameters.

See alsosendQuery() andQWSServer::sendIMQuery().

[virtual]void QWSInputMethod::reset()

Resets the state of the input method.

If the input method is in compose mode, i.e., the input method is actively composing a preedit string, the default implementation callssendEvent() with empty preedit and commit strings; otherwise it does nothing. Reimplement this function to alter this behavior.

See alsosendEvent().

[protected]void QWSInputMethod::sendCommitString(constQString & commitString,int replaceFromPosition = 0,int replaceLength = 0)

Sends an event encapsulating the givencommitString, to the focus widget.

Note that this will cause the input method to leave compose mode, i.e., the input method will no longer be actively composing the preedit string.

If the specifiedreplaceLength is greater than 0, the commit string will replace the given number of characters of the receiving widget's previous text, starting at the givenreplaceFromPosition relative to the start of the current preedit string.

Internally, the event is represented by aQWSEvent object of theIMEvent type.

See alsosendEvent() andsendPreeditString().

[protected]void QWSInputMethod::sendEvent(constQInputMethodEvent * event)

Sends the givenevent to the focus widget.

TheQInputMethodEvent class is derived fromQWSEvent, i.e., the givenevent is aQWSEvent object of theIMEvent type.

See alsosendPreeditString(),sendCommitString(), andreset().

[protected]void QWSInputMethod::sendMouseEvent(constQPoint & position,int state,int wheel)

Sends a mouse event specified by the givenposition,state andwheel parameters.

The givenposition will be transformed if the screen coordinates do not match the pointer device coordinates.

Note that the event will be not be tested by the active input method, but calling the QWSServer::sendMouseEvent() function will make the current input method filter the event.

See alsomouseHandler() andsendEvent().

[protected]void QWSInputMethod::sendPreeditString(constQString & preeditString,int cursorPosition,int selectionLength = 0)

Sends an event encapsulating the givenpreeditString, to the focus widget.

The specifiedselectionLength is the number of characters to be marked as selected (starting at the givencursorPosition). IfselectionLength is negative, the textbeforecursorPosition is marked.

The preedit string is marked withQInputContext::PreeditFormat, and the selected part is marked withQInputContext::SelectionFormat.

Sending an input method event with a non-empty preedit string will cause the input method to enter compose mode. Sending an input method event with an empty preedit string will cause the input method to leave compose mode, i.e., the input method will no longer be actively composing the preedit string.

Internally, the event is represented by aQWSEvent object of theIMEvent type.

See alsosendEvent() andsendCommitString().

[protected]void QWSInputMethod::sendQuery(int property)

Sends an input method query (internally encapsulated by aQWSEvent of theIMQuery type) for the specifiedproperty.

To receive responses to input method queries, the virtualqueryResponse() function must be reimplemented.

See alsoqueryResponse() andQWSServer::sendIMQuery().

[protected]uint QWSInputMethod::setInputResolution(bool isHigh)

Sets and returns the number of bits shifted to go from pointer resolution to screen resolution when filtering mouse input.

IfisHigh is true and the device has a pointer device resolution twice or more of the screen resolution, the positions passed to thefilter() function will be presented at the higher resolution; otherwise the resolution will be equal to that of the screen resolution.

See alsoinputResolutionShift() andfilter().

[virtual]void QWSInputMethod::updateHandler(int type)

Handles update events including resets and focus changes. The update events are specified by the giventype which is one of theUpdateType enum values.

Note that reimplementations of this function must call the base implementation for all cases that it does not handle itself.

See alsoUpdateType.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp