Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QInputContext Class Reference
[QtGui module]

The QInputContext class abstracts the input method dependent data and composing state. More...

 #include <QInputContext>

Inherits QObject.


Public Types

enum StandardFormat { PreeditFormat, SelectionFormat }

Public Functions

QInputContext ( QObject * parent = 0 )
virtual ~QInputContext ()
virtual QList<QAction *> actions ()
virtual bool filterEvent ( const QEvent * event )
QWidget * focusWidget () const
virtual QFont font () const
virtual QString identifierName () = 0
virtual bool isComposing () const = 0
virtual QString language () = 0
virtual void mouseHandler ( int x, QMouseEvent * event )
virtual void reset () = 0
void sendEvent ( const QInputMethodEvent & event )
virtual void setFocusWidget ( QWidget * widget )
QTextFormat standardFormat ( StandardFormat s ) const
virtual bool symbianFilterEvent ( QWidget * keywidget, const QSymbianEvent * event )
virtual void update ()
virtual void widgetDestroyed ( QWidget * widget )
virtual bool x11FilterEvent ( QWidget * keywidget, XEvent * event )
  • 29 public functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 5 static public members inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

The QInputContext class abstracts the input method dependent data and composing state.

An input method is responsible for inputting complex text that cannot be inputted via simple keymap. It converts a sequence of input events (typically key events) into a text string through the input method specific converting process. The class of the processes are widely ranging from simple finite state machine to complex text translator that pools a whole paragraph of a text with text editing capability to perform grammar and semantic analysis.

To abstract such different input method specific intermediate information, Qt offers the QInputContext as base class. The concept is well known as 'input context' in the input method domain. An input context is created for a text widget in response to a demand. It is ensured that an input context is prepared for an input method before input to a text widget.

Multiple input contexts that belong to a single input method may concurrently coexist. Suppose multi-window text editor. Each text widget of window A and B holds different QInputContext instance which contains different state information such as partially composed text.

Groups of Functions

ContextFunctions
Receiving informationx11FilterEvent(), filterEvent(), mouseHandler()
Sending back composed textsendEvent()
State change notificationsetFocusWidget(), reset()
Context informationidentifierName(), language(), font(), isComposing()

Licensing Information

Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.

This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own license. You may use this file under your Qt license. Following description is copied from their original file headers. Contact immodule-qt@freedesktop.org if any conditions of this licensing are not clear to you.

See also QInputContextPlugin, QInputContextFactory, and QApplication::setInputContext().


Member Type Documentation

enum QInputContext::StandardFormat

ConstantValueDescription
QInputContext::PreeditFormat0The preedit text.
QInputContext::SelectionFormat1The selection text.

See also standardFormat().


Member Function Documentation

QInputContext::QInputContext ( QObject * parent = 0 )

Constructs an input context with the given parent.

QInputContext::~QInputContext ()   [virtual]

Destroys the input context.

QList<QAction *> QInputContext::actions ()   [virtual]

This is a preliminary interface for Qt 4.

bool QInputContext::filterEvent ( const QEvent * event )   [virtual]

This function can be reimplemented in a subclass to filter input events.

Return true if the event has been consumed. Otherwise, the unfiltered event will be forwarded to widgets as ordinary way. Although the input events have accept() and ignore() methods, leave it untouched.

event is currently restricted to events of these types:

  • CloseSoftwareInputPanel
  • KeyPress
  • KeyRelease
  • MouseButtonDblClick
  • MouseButtonPress
  • MouseButtonRelease
  • MouseMove
  • RequestSoftwareInputPanel

But some input method related events such as QWheelEvent or QTabletEvent may be added in future.

The filtering opportunity is always given to the input context as soon as possible. It has to be taken place before any other key event consumers such as eventfilters and accelerators because some input methods require quite various key combination and sequences. It often conflicts with accelerators and so on, so we must give the input context the filtering opportunity first to ensure all input methods work properly regardless of application design.

Ordinary input methods require discrete key events to work properly, so Qt's key compression is always disabled for any input contexts.

See also QKeyEvent and x11FilterEvent().

QWidget * QInputContext::focusWidget () const

Returns the widget that has an input focus for this input context.

The return value may differ from holderWidget() if the input context is shared between several text widgets.

Warning: To ensure platform independence and support flexible configuration of widgets, ordinary input methods should not call this function directly.

See also setFocusWidget().

QFont QInputContext::font () const   [virtual]

Returns the font of the current input widget

QString QInputContext::identifierName ()   [pure virtual]

This function must be implemented in any subclasses to return the identifier name of the input method.

Return value is the name to identify and specify input methods for the input method switching mechanism and so on. The name has to be consistent with QInputContextPlugin::keys(). The name has to consist of ASCII characters only.

There are two different names with different responsibility in the input method domain. This function returns one of them. Another name is called 'display name' that stands for the name for endusers appeared in a menu and so on.

See also QInputContextPlugin::keys() and QInputContextPlugin::displayName().

bool QInputContext::isComposing () const   [pure virtual]

This function indicates whether InputMethodStart event had been sent to the current focus widget. It is ensured that an input context can send InputMethodCompose or InputMethodEnd event safely if this function returned true.

The state is automatically being tracked through sendEvent().

See also sendEvent().

QString QInputContext::language ()   [pure virtual]

This function must be implemented in any subclasses to return a language code (e.g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...) of the input context. If the input context can handle multiple languages, return the currently used one. The name has to be consistent with QInputContextPlugin::language().

This information will be used by language tagging feature in QInputMethodEvent. It is required to distinguish unified han characters correctly. It enables proper font and character code handling. Suppose CJK-awared multilingual web browser (that automatically modifies fonts in CJK-mixed text) and XML editor (that automatically inserts lang attr).

void QInputContext::mouseHandler ( int x, QMouseEvent * event )   [virtual]

This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text. You can use the function to implement mouse-oriented user interface such as text selection or popup menu for candidate selection.

The x parameter is the offset within the string that was sent with the InputMethodCompose event. The alteration boundary of x is ensured as character boundary of preedit string accurately.

The event parameter is the event that was sent to the editor widget. The event type is QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick or QEvent::MouseMove. The event's button and state indicate the kind of operation that was performed.

void QInputContext::reset ()   [pure virtual]

This function can be reimplemented in a subclass to reset the state of the input method.

This function is called by several widgets to reset input state. For example, a text widget call this function before inserting a text to make widget ready to accept a text.

Default implementation is sufficient for simple input method. You can override this function to reset external input method engines in complex input method. In the case, call QInputContext::reset() to ensure proper termination of inputting.

You must not send any QInputMethodEvent except empty InputMethodEnd event using QInputContext::reset() at reimplemented reset(). It will break input state consistency.

void QInputContext::sendEvent ( const QInputMethodEvent & event )

Sends an input method event specified by event to the current focus widget. Implementations of QInputContext should call this method to send the generated input method events and not QApplication::sendEvent(), as the events might have to get dispatched to a different application on some platforms.

Some complex input methods route the handling to several child contexts (e.g. to enable language switching). To account for this, QInputContext will check if the parent object is a QInputContext. If yes, it will call the parents sendEvent() implementation instead of sending the event directly.

See also QInputMethodEvent.

void QInputContext::setFocusWidget ( QWidget * widget )   [virtual]

Sets the widget that has an input focus for this input context.

Warning: Ordinary input methods must not call this function directly.

See also focusWidget().

QTextFormat QInputContext::standardFormat ( StandardFormat s ) const

Returns a QTextFormat object that specifies the format for component s.

bool QInputContext::symbianFilterEvent ( QWidget * keywidget, const QSymbianEvent * event )   [virtual]

This function may be overridden only if input method is depending on Symbian and you need raw Symbian events. Otherwise, this function must not.

This function is designed to filter raw key events on Symbian, but other input methods may use this to implement some special features.

Return true if the event has been consumed. Otherwise, the unfiltered event will be translated into QEvent and forwarded to filterEvent(). Filtering at both symbianFilterEvent() and filterEvent() in single input method is allowed.

keywidget is a client widget into which a text is inputted. event is inputted QSymbianEvent.

This function was introduced in Qt 4.6.

See also filterEvent().

void QInputContext::update ()   [virtual]

This virtual function is called when a state in the focus widget has changed. QInputContext can then use QWidget::inputMethodQuery() to query the new state of the widget.

void QInputContext::widgetDestroyed ( QWidget * widget )   [virtual]

This virtual function is called when the specified widget is destroyed. The widget is a widget on which this input context is installed.

bool QInputContext::x11FilterEvent ( QWidget * keywidget, XEvent * event )   [virtual]

This function may be overridden only if input method is depending on X11 and you need raw XEvent. Otherwise, this function must not.

This function is designed to filter raw key events for XIM, but other input methods may use this to implement some special features such as distinguishing Shift_L and Shift_R.

Return true if the event has been consumed. Otherwise, the unfiltered event will be translated into QEvent and forwarded to filterEvent(). Filtering at both x11FilterEvent() and filterEvent() in single input method is allowed.

keywidget is a client widget into which a text is inputted. event is inputted XEvent.

See also filterEvent().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web