Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 4345

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qevent.cpp -->
<head>
  <title>Qt 4.6: QInputMethodEvent Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QInputMethodEvent"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QInputMethodEvent Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span>
</h1>
<p>The QInputMethodEvent class provides parameters for input method events. <a href="#details">More...</a></p>
<pre> #include &lt;QInputMethodEvent&gt;</pre><p>Inherits <a href="qevent.html">QEvent</a>.</p>
<ul>
<li><a href="qinputmethodevent-members.html">List of all members, including inherited members</a></li>
</ul>
<hr />
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent-attribute.html">Attribute</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#AttributeType-enum">AttributeType</a></b> { TextFormat, Cursor, Language, Ruby, Selection }</td></tr>
</table>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#QInputMethodEvent">QInputMethodEvent</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#QInputMethodEvent-2">QInputMethodEvent</a></b> ( const QString &amp; <i>preeditText</i>, const QList&lt;Attribute&gt; &amp; <i>attributes</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#QInputMethodEvent-3">QInputMethodEvent</a></b> ( const QInputMethodEvent &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const QList&lt;Attribute&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#attributes">attributes</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const QString &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#commitString">commitString</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const QString &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#preeditString">preeditString</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#replacementLength">replacementLength</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#replacementStart">replacementStart</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qinputmethodevent.html#setCommitString">setCommitString</a></b> ( const QString &amp; <i>commitString</i>, int <i>replaceFrom</i> = 0, int <i>replaceLength</i> = 0 )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>6 public functions inherited from <a href="qevent.html#public-functions">QEvent</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>1 property inherited from <a href="qevent.html#properties">QEvent</a></li>
<li><div class="fn"></div>1 static public member inherited from <a href="qevent.html#static-public-members">QEvent</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QInputMethodEvent class provides parameters for input method events.</p>
<p>Input method events are sent to widgets when an input method is used to enter text into a widget. Input methods are widely used to enter text for languages with non-Latin alphabets.</p>
<p>Note that when creating custom text editing widgets, the <a href="qt.html#WidgetAttribute-enum">Qt::WA_InputMethodEnabled</a> window attribute must be set explicitly (using the <a href="qwidget.html#setAttribute">QWidget::setAttribute</a>() function) in order to receive input method events.</p>
<p>The events are of interest to authors of keyboard entry widgets who want to be able to correctly handle languages with complex character input. Text input in such languages is usually a three step process:</p>
<ol type="1">
<li><b>Starting to Compose</b><p>When the user presses the first key on a keyboard, an input context is created. This input context will contain a string of the typed characters.</p>
</li>
<li><b>Composing</b><p>With every new key pressed, the input method will try to create a matching string for the text typed so far called preedit string. While the input context is active, the user can only move the cursor inside the string belonging to this input context.</p>
</li>
<li><b>Completing</b><p>At some point, the user will activate a user interface component (perhaps using a particular key) where they can choose from a number of strings matching the text they have typed so far. The user can either confirm their choice cancel the input; in either case the input context will be closed.</p>
</li>
</ol>
<p>QInputMethodEvent models these three stages, and transfers the information needed to correctly render the intermediate result. A QInputMethodEvent has two main parameters: <a href="qinputmethodevent.html#preeditString">preeditString</a>() and <a href="qinputmethodevent.html#commitString">commitString</a>(). The <a href="qinputmethodevent.html#preeditString">preeditString</a>() parameter gives the currently active preedit string. The <a href="qinputmethodevent.html#commitString">commitString</a>() parameter gives a text that should get added to (or replace parts of) the text of the editor widget. It usually is a result of the input operations and has to be inserted to the widgets text directly before the preedit string.</p>
<p>If the <a href="qinputmethodevent.html#commitString">commitString</a>() should replace parts of the of the text in the editor, <a href="qinputmethodevent.html#replacementLength">replacementLength</a>() will contain the number of characters to be replaced. <a href="qinputmethodevent.html#replacementStart">replacementStart</a>() contains the position at which characters are to be replaced relative from the start of the preedit string.</p>
<p>A number of attributes control the visual appearance of the preedit string (the visual appearance of text outside the preedit string is controlled by the widget only). The <a href="qinputmethodevent.html#AttributeType-enum">AttributeType</a> enum describes the different attributes that can be set.</p>
<p>A class implementing <a href="qwidget.html#inputMethodEvent">QWidget::inputMethodEvent</a>() or <a href="qgraphicsitem.html#inputMethodEvent">QGraphicsItem::inputMethodEvent</a>() should at least understand and honor the <a href="qinputmethodevent.html#AttributeType-enum">TextFormat</a> and <a href="qinputmethodevent.html#AttributeType-enum">Cursor</a> attributes.</p>
<p>Since input methods need to be able to query certain properties from the widget or graphics item, subclasses must also implement <a href="qwidget.html#inputMethodQuery">QWidget::inputMethodQuery</a>() and <a href="qgraphicsitem.html#inputMethodQuery">QGraphicsItem::inputMethodQuery</a>(), respectively.</p>
<p>When receiving an input method event, the text widget has to performs the following steps:</p>
<ol type="1">
<li>If the widget has selected text, the selected text should get removed.</li>
<li>Remove the text starting at <a href="qinputmethodevent.html#replacementStart">replacementStart</a>() with length <a href="qinputmethodevent.html#replacementLength">replacementLength</a>() and replace it by the <a href="qinputmethodevent.html#commitString">commitString</a>(). If <a href="qinputmethodevent.html#replacementLength">replacementLength</a>() is 0, <a href="qinputmethodevent.html#replacementStart">replacementStart</a>() gives the insertion position for the <a href="qinputmethodevent.html#commitString">commitString</a>().<p>When doing replacement the area of the preedit string is ignored, thus a replacement starting at -1 with a length of 2 will remove the last character before the preedit string and the first character afterwards, and insert the commit string directly before the preedit string.</p>
<p>If the widget implements undo/redo, this operation gets added to the undo stack.</p>
</li>
<li>If there is no current preedit string, insert the <a href="qinputmethodevent.html#preeditString">preeditString</a>() at the current cursor position; otherwise replace the previous preeditString with the one received from this event.<p>If the widget implements undo/redo, the <a href="qinputmethodevent.html#preeditString">preeditString</a>() should not influence the undo/redo stack in any way.</p>
<p>The widget should examine the list of attributes to apply to the preedit string. It has to understand at least the <a href="qinputmethodevent.html#AttributeType-enum">TextFormat</a> and Cursor attributes and render them as specified.</p>
</li>
</ol>
<p>See also <a href="qinputcontext.html">QInputContext</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<a name="//apple_ref/cpp/tag/QInputMethodEvent/AttributeType"></a>
<a name="//apple_ref/cpp/econst/QInputMethodEvent/TextFormat"></a>
<a name="//apple_ref/cpp/econst/QInputMethodEvent/Cursor"></a>
<a name="//apple_ref/cpp/econst/QInputMethodEvent/Language"></a>
<a name="//apple_ref/cpp/econst/QInputMethodEvent/Ruby"></a>
<a name="//apple_ref/cpp/econst/QInputMethodEvent/Selection"></a>
<h3 class="fn"><a name="AttributeType-enum"></a>enum QInputMethodEvent::AttributeType</h3>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QInputMethodEvent::TextFormat</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">A <a href="qtextcharformat.html">QTextCharFormat</a> for the part of the preedit string specified by start and length. value contains a <a href="qvariant.html">QVariant</a> of type <a href="qtextformat.html">QTextFormat</a> specifying rendering of this part of the preedit string. There should be at most one format for every part of the preedit string. If several are specified for any character in the string the behaviour is undefined. A conforming implementation has to at least honor the backgroundColor, textColor and fontUnderline properties of the format.</td></tr>
<tr><td valign="top"><tt>QInputMethodEvent::Cursor</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">If set, a cursor should be shown inside the preedit string at position start. The length variable determines whether the cursor is visible or not. If the length is 0 the cursor is invisible. If value is a <a href="qvariant.html">QVariant</a> of type <a href="qcolor.html">QColor</a> this color will be used for rendering the cursor, otherwise the color of the surrounding text will be used. There should be at most one Cursor attribute per event. If several are specified the behaviour is undefined.</td></tr>
<tr><td valign="top"><tt>QInputMethodEvent::Language</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">The variant contains a <a href="qlocale.html">QLocale</a> object specifying the language of a certain part of the preedit string. There should be at most one language set for every part of the preedit string. If several are specified for any character in the string the behavior is undefined.</td></tr>
<tr><td valign="top"><tt>QInputMethodEvent::Ruby</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">The ruby text for a part of the preedit string. There should be at most one ruby text set for every part of the preedit string. If several are specified for any character in the string the behaviour is undefined.</td></tr>
<tr><td valign="top"><tt>QInputMethodEvent::Selection</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">If set, the edit cursor should be moved to the specified position in the editor text contents. In contrast with <tt>Cursor</tt>, this attribute does not work on the preedit text, but on the surrounding text. The cursor will be moved after the commit string has been committed, and the preedit string will be located at the new edit position. The start position specifies the new position and the length variable can be used to set a selection starting from that point. The value is unused.</td></tr>
</table></p>
<p>See also <a href="qinputmethodevent-attribute.html">Attribute</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/QInputMethodEvent"></a>
<h3 class="fn"><a name="QInputMethodEvent"></a>QInputMethodEvent::QInputMethodEvent ()</h3>
<p>Constructs an event of type <a href="qevent.html#Type-enum">QEvent::InputMethod</a>. The <a href="qinputmethodevent.html#attributes">attributes</a>(), <a href="qinputmethodevent.html#preeditString">preeditString</a>(), <a href="qinputmethodevent.html#commitString">commitString</a>(), <a href="qinputmethodevent.html#replacementStart">replacementStart</a>(), and <a href="qinputmethodevent.html#replacementLength">replacementLength</a>() are initialized to default values.</p>
<p>See also <a href="qinputmethodevent.html#setCommitString">setCommitString</a>().</p>
<h3 class="fn"><a name="QInputMethodEvent-2"></a>QInputMethodEvent::QInputMethodEvent ( const <a href="qstring.html">QString</a> &amp; <i>preeditText</i>, const <a href="qlist.html">QList</a>&lt;<a href="qinputmethodevent-attribute.html">Attribute</a>&gt; &amp; <i>attributes</i> )</h3>
<p>Construcs an event of type <a href="qevent.html#Type-enum">QEvent::InputMethod</a>. The preedit text is set to <i>preeditText</i>, the attributes to <i>attributes</i>.</p>
<p>The <a href="qinputmethodevent.html#commitString">commitString</a>(), <a href="qinputmethodevent.html#replacementStart">replacementStart</a>(), and <a href="qinputmethodevent.html#replacementLength">replacementLength</a>() values can be set using <a href="qinputmethodevent.html#setCommitString">setCommitString</a>().</p>
<p>See also <a href="qinputmethodevent.html#preeditString">preeditString</a>() and <a href="qinputmethodevent.html#attributes">attributes</a>().</p>
<h3 class="fn"><a name="QInputMethodEvent-3"></a>QInputMethodEvent::QInputMethodEvent ( const QInputMethodEvent &amp; <i>other</i> )</h3>
<p>Constructs a copy of <i>other</i>.</p>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/attributes"></a>
<h3 class="fn"><a name="attributes"></a>const <a href="qlist.html">QList</a>&lt;<a href="qinputmethodevent-attribute.html">Attribute</a>&gt; &amp; QInputMethodEvent::attributes () const</h3>
<p>Returns the list of attributes passed to the <a href="qinputmethodevent.html">QInputMethodEvent</a> constructor. The attributes control the visual appearance of the preedit string (the visual appearance of text outside the preedit string is controlled by the widget only).</p>
<p>See also <a href="qinputmethodevent.html#preeditString">preeditString</a>() and <a href="qinputmethodevent-attribute.html">Attribute</a>.</p>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/commitString"></a>
<h3 class="fn"><a name="commitString"></a>const <a href="qstring.html">QString</a> &amp; QInputMethodEvent::commitString () const</h3>
<p>Returns the text that should get added to (or replace parts of) the text of the editor widget. It usually is a result of the input operations and has to be inserted to the widgets text directly before the preedit string.</p>
<p>See also <a href="qinputmethodevent.html#setCommitString">setCommitString</a>(), <a href="qinputmethodevent.html#preeditString">preeditString</a>(), <a href="qinputmethodevent.html#replacementStart">replacementStart</a>(), and <a href="qinputmethodevent.html#replacementLength">replacementLength</a>().</p>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/preeditString"></a>
<h3 class="fn"><a name="preeditString"></a>const <a href="qstring.html">QString</a> &amp; QInputMethodEvent::preeditString () const</h3>
<p>Returns the preedit text, i.e&#x2e; the text before the user started editing it.</p>
<p>See also <a href="qinputmethodevent.html#commitString">commitString</a>() and <a href="qinputmethodevent.html#attributes">attributes</a>().</p>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/replacementLength"></a>
<h3 class="fn"><a name="replacementLength"></a>int QInputMethodEvent::replacementLength () const</h3>
<p>Returns the number of characters to be replaced in the preedit string.</p>
<p>See also <a href="qinputmethodevent.html#replacementStart">replacementStart</a>() and <a href="qinputmethodevent.html#setCommitString">setCommitString</a>().</p>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/replacementStart"></a>
<h3 class="fn"><a name="replacementStart"></a>int QInputMethodEvent::replacementStart () const</h3>
<p>Returns the position at which characters are to be replaced relative from the start of the preedit string.</p>
<p>See also <a href="qinputmethodevent.html#replacementLength">replacementLength</a>() and <a href="qinputmethodevent.html#setCommitString">setCommitString</a>().</p>
<a name="//apple_ref/cpp/instm/QInputMethodEvent/setCommitString"></a>
<h3 class="fn"><a name="setCommitString"></a>void QInputMethodEvent::setCommitString ( const <a href="qstring.html">QString</a> &amp; <i>commitString</i>, int <i>replaceFrom</i> = 0, int <i>replaceLength</i> = 0 )</h3>
<p>Sets the commit string to <i>commitString</i>.</p>
<p>The commit string is the text that should get added to (or replace parts of) the text of the editor widget. It usually is a result of the input operations and has to be inserted to the widgets text directly before the preedit string.</p>
<p>If the commit string should replace parts of the of the text in the editor, <i>replaceLength</i> specifies the number of characters to be replaced. <i>replaceFrom</i> specifies the position at which characters are to be replaced relative from the start of the preedit string.</p>
<p>See also <a href="qinputmethodevent.html#commitString">commitString</a>(), <a href="qinputmethodevent.html#replacementStart">replacementStart</a>(), and <a href="qinputmethodevent.html#replacementLength">replacementLength</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>