Classes - Annotated - Tree - Functions - Home - Structure

QIMEvent Class Reference

This class contains parameters for input method events. More...

#include <qevent.h>

Inherits QEvent.

List of all member functions.

Public Members


Detailed Description

This class contains parameters for input method events.

Input method events are send to widgets, when an input method is used to enter text into a widget. Input methods are widely used in asian languages as a way to enter text.

The events are of interest to widgets, that accept keyboard input and want to be able to correctly handle asian languages. Text input in asian languages is usually a three step process. When the user presses the first key on a keyboard an input context is created. This input context will contain a string with the typed characters. With every new key pressed, the input method will try to create a matching string for the text typed so far.

While the input context is active, the user can move the cursor only inside the string belonging to this inut context. At some point, when the user presses space, he gets into the second stage, where he can choose from a number of strings that fit to the text he typed so far. Typing return will then confirm his choice and the input context will be closed.

These three stages are represented by three different types of events. The IMStartEvent, IMComposeEvent and IMEndEvent. When a new input context is created, and IMStartEvent will be send to the widget and delivered to the QWidget::imStartEvent method. The widget can then update internal data structures to reflect this.

After this, an IMComposeEvent will be send to the widget with every key the user presses. It will contain the current composition string the widget has to show and the current cursor position inside the composition string. This string is temporary and can change with every key the user types, so the widget will need to store the state before the composition started (the state it had when it received the IMStartEvent). IMComposeEvents will be delivered to the QWIdget::imComposeEvent method.

Usually, widgets try to mark the part of the text that is part of the current composition in a way visible to the user. Mostly this is achieved by using eg. dotted underlines.

After the user selected the final string, and IMEndEvent will be send to the widget. The event contains the final string the user selected. This string has to be accepted as the final text the user entered, and the intermediate composition string should be cleared. These events are delivered to QWidget::imEndEvent.


Member Function Documentation

QIMEvent::QIMEvent ( Type type, const QString & text, int cursorPosition )

Constructs a new QIMEvent with accept flag set to FALSE. Type can be one of QEvent::IMStartEvent, QEvent::IMComposeEvents and QEvent::IMEndEvent. text describes the current compostion string and cursorPosition the current position of the cursor inside text.

void QIMEvent::accept ()

Sets the accept flag of the input method event object.

Setting the accept parameter indicates that the receiver of the event processed the input method event.

The accept flag is not set by default.

See also ignore().

int QIMEvent::cursorPos () const

Returns the current cursor position inside the composition string. Will return 0 for IMStartEvent and IMEndEvent.

void QIMEvent::ignore ()

Clears the accept flag parameter of the input method event object.

Clearing the accept parameter indicates that the event receiver does not want the input method event.

The accept flag is cleared by default.

See also accept().

bool QIMEvent::isAccepted () const

Returns TRUE if the receiver of the event processed the event.

const QString & QIMEvent::text () const

Returns the composition text. This is a null string for an IMStartEvent, and contains the final accepted string in the IMEndEvent.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta1-beta1