<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QCompleter Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QCompleter Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QCompleter class provides completions based on an item model. <a href="#details">More...</a></p> <p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qcompleter.html#CompletionMode-enum">CompletionMode</a></b> { PopupCompletion, UnfilteredPopupCompletion, InlineCompletion }</li><li><div class="fn" />enum <b><a href="qcompleter.html#ModelSorting-enum">ModelSorting</a></b> { UnsortedModel, CaseSensitivelySortedModel, CaseInsensitivelySortedModel }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qcompleter.html#QCompleter">__init__</a></b> (<i>self</i>, QObject <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qcompleter.html#QCompleter-2">__init__</a></b> (<i>self</i>, QAbstractItemModel <i>model</i>, QObject <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qcompleter.html#QCompleter-3">__init__</a></b> (<i>self</i>, QStringList <i>list</i>, QObject <i>parent</i> = None)</li><li><div class="fn" />Qt.CaseSensitivity <b><a href="qcompleter.html#caseSensitivity">caseSensitivity</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#complete">complete</a></b> (<i>self</i>, QRect <i>rect</i> = QRect())</li><li><div class="fn" />int <b><a href="qcompleter.html#completionColumn">completionColumn</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qcompleter.html#completionCount">completionCount</a></b> (<i>self</i>)</li><li><div class="fn" />CompletionMode <b><a href="qcompleter.html#completionMode">completionMode</a></b> (<i>self</i>)</li><li><div class="fn" />QAbstractItemModel <b><a href="qcompleter.html#completionModel">completionModel</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qcompleter.html#completionPrefix">completionPrefix</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qcompleter.html#completionRole">completionRole</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qcompleter.html#currentCompletion">currentCompletion</a></b> (<i>self</i>)</li><li><div class="fn" />QModelIndex <b><a href="qcompleter.html#currentIndex">currentIndex</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qcompleter.html#currentRow">currentRow</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qcompleter.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />bool <b><a href="qcompleter.html#eventFilter">eventFilter</a></b> (<i>self</i>, QObject <i>o</i>, QEvent <i>e</i>)</li><li><div class="fn" />int <b><a href="qcompleter.html#maxVisibleItems">maxVisibleItems</a></b> (<i>self</i>)</li><li><div class="fn" />QAbstractItemModel <b><a href="qcompleter.html#model">model</a></b> (<i>self</i>)</li><li><div class="fn" />ModelSorting <b><a href="qcompleter.html#modelSorting">modelSorting</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qcompleter.html#pathFromIndex">pathFromIndex</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />QAbstractItemView <b><a href="qcompleter.html#popup">popup</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCaseSensitivity">setCaseSensitivity</a></b> (<i>self</i>, Qt.CaseSensitivity <i>caseSensitivity</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionColumn">setCompletionColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionMode">setCompletionMode</a></b> (<i>self</i>, CompletionMode <i>mode</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionPrefix">setCompletionPrefix</a></b> (<i>self</i>, QString <i>prefix</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionRole">setCompletionRole</a></b> (<i>self</i>, int <i>role</i>)</li><li><div class="fn" />bool <b><a href="qcompleter.html#setCurrentRow">setCurrentRow</a></b> (<i>self</i>, int <i>row</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setMaxVisibleItems">setMaxVisibleItems</a></b> (<i>self</i>, int <i>maxItems</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setModel">setModel</a></b> (<i>self</i>, QAbstractItemModel <i>c</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setModelSorting">setModelSorting</a></b> (<i>self</i>, ModelSorting <i>sorting</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setPopup">setPopup</a></b> (<i>self</i>, QAbstractItemView <i>popup</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setWidget">setWidget</a></b> (<i>self</i>, QWidget <i>widget</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setWrapAround">setWrapAround</a></b> (<i>self</i>, bool <i>wrap</i>)</li><li><div class="fn" />QStringList <b><a href="qcompleter.html#splitPath">splitPath</a></b> (<i>self</i>, QString <i>path</i>)</li><li><div class="fn" />QWidget <b><a href="qcompleter.html#widget">widget</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qcompleter.html#wrapAround">wrapAround</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qcompleter.html#activated">activated</a></b> (const QString&)</li><li><div class="fn" />void <b><a href="qcompleter.html#activated-2">activated</a></b> (const QModelIndex&)</li><li><div class="fn" />void <b><a href="qcompleter.html#highlighted">highlighted</a></b> (const QString&)</li><li><div class="fn" />void <b><a href="qcompleter.html#highlighted-2">highlighted</a></b> (const QModelIndex&)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QCompleter class provides completions based on an item model.</p> <p>You can use QCompleter to provide auto completions in any Qt widget, such as <a href="qlineedit.html">QLineEdit</a> and <a href="qcombobox.html">QComboBox</a>. When the user starts typing a word, QCompleter suggests possible ways of completing the word, based on a word list. The word list is provided as a <a href="qabstractitemmodel.html">QAbstractItemModel</a>. (For simple applications, where the word list is static, you can pass a <a href="qstringlist.html">QStringList</a> to QCompleter's constructor.)</p> <a id="basic-usage" name="basic-usage" /> <h3>Basic Usage</h3> <p>A QCompleter is used typically with a <a href="qlineedit.html">QLineEdit</a> or <a href="qcombobox.html">QComboBox</a>. For example, here's how to provide auto completions from a simple word list in a <a href="qlineedit.html">QLineEdit</a>:</p> <pre class="cpp"> <span class="type"><a href="qstringlist.html">QStringList</a></span> wordList; wordList <span class="operator"><</span><span class="operator"><</span> <span class="string">"alpha"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"omega"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"omicron"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"zeta"</span>; <span class="type"><a href="qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>lineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>(<span class="keyword">this</span>); <span class="type">QCompleter</span> <span class="operator">*</span>completer <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QCompleter</span>(wordList<span class="operator">,</span> <span class="keyword">this</span>); completer<span class="operator">-</span><span class="operator">></span><a href="qcompleter.html#caseSensitivity-prop">setCaseSensitivity</a>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>CaseInsensitive); lineEdit<span class="operator">-</span><span class="operator">></span>setCompleter(completer); </pre> <p>A <a href="qfilesystemmodel.html">QFileSystemModel</a> can be used to provide auto completion of file names. For example:</p> <pre class="cpp"> <span class="type">QCompleter</span> <span class="operator">*</span>completer <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QCompleter</span>(<span class="keyword">this</span>); completer<span class="operator">-</span><span class="operator">></span><a href="qcompleter.html#setModel">setModel</a>(<span class="keyword">new</span> <span class="type"><a href="qdirmodel.html">QDirModel</a></span>(completer)); lineEdit<span class="operator">-</span><span class="operator">></span>setCompleter(completer); </pre> <p>To set the model on which QCompleter should operate, call <a href="qcompleter.html#setModel">setModel</a>(). By default, QCompleter will attempt to match the <a href="qcompleter.html#completionPrefix-prop">completion prefix</a> (i.e., the word that the user has started typing) against the <a href="qt.html#ItemDataRole-enum">Qt.EditRole</a> data stored in column 0 in the model case sensitively. This can be changed using <a href="qcompleter.html#completionRole-prop">setCompletionRole</a>(), <a href="qcompleter.html#completionColumn-prop">setCompletionColumn</a>(), and <a href="qcompleter.html#caseSensitivity-prop">setCaseSensitivity</a>().</p> <p>If the model is sorted on the column and role that are used for completion, you can call <a href="qcompleter.html#modelSorting-prop">setModelSorting</a>() with either <a href="qcompleter.html#ModelSorting-enum">QCompleter.CaseSensitivelySortedModel</a> or <a href="qcompleter.html#ModelSorting-enum">QCompleter.CaseInsensitivelySortedModel</a> as the argument. On large models, this can lead to significant performance improvements, because QCompleter can then use binary search instead of linear search.</p> <p>The model can be a <a href="qabstractlistmodel.html">list model</a>, a <a href="qabstracttablemodel.html">table model</a>, or a <a href="qabstractitemmodel.html">tree model</a>. Completion on tree models is slightly more involved and is covered in the <a href="#handling-tree-models">Handling Tree Models</a> section below.</p> <p>The <a href="qcompleter.html#completionMode-prop">completionMode</a>() determines the mode used to provide completions to the user.</p> <a id="iterating-through-completions" name="iterating-through-completions" /> <h3>Iterating Through Completions</h3> <p>To retrieve a single candidate string, call <a href="qcompleter.html#completionPrefix-prop">setCompletionPrefix</a>() with the text that needs to be completed and call <a href="qcompleter.html#currentCompletion">currentCompletion</a>(). You can iterate through the list of completions as below:</p> <pre class="cpp"> <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; completer<span class="operator">-</span><span class="operator">></span>setCurrentRow(i); i<span class="operator">+</span><span class="operator">+</span>) <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> completer<span class="operator">-</span><span class="operator">></span><a href="qcompleter.html#currentCompletion">currentCompletion</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">" is match number "</span> <span class="operator"><</span><span class="operator"><</span> i; </pre> <p><a href="qcompleter.html#completionCount">completionCount</a>() returns the total number of completions for the current prefix. <a href="qcompleter.html#completionCount">completionCount</a>() should be avoided when possible, since it requires a scan of the entire model.</p> <a id="the-completion-model" name="the-completion-model" /> <h3>The Completion Model</h3> <p><a href="qcompleter.html#completionModel">completionModel</a>() return a list model that contains all possible completions for the current completion prefix, in the order in which they appear in the model. This model can be used to display the current completions in a custom view. Calling <a href="qcompleter.html#completionPrefix-prop">setCompletionPrefix</a>() automatically refreshes the completion model.</p> <a id="handling-tree-models" name="handling-tree-models" /> <h3>Handling Tree Models</h3> <p>QCompleter can look for completions in tree models, assuming that any item (or sub-item or sub-sub-item) can be unambiguously represented as a string by specifying the path to the item. The completion is then performed one level at a time.</p> <p>Let's take the example of a user typing in a file system path. The model is a (hierarchical) <a href="qfilesystemmodel.html">QFileSystemModel</a>. The completion occurs for every element in the path. For example, if the current text is <tt>C:\Wind</tt>, QCompleter might suggest <tt>Windows</tt> to complete the current path element. Similarly, if the current text is <tt>C:\Windows\Sy</tt>, QCompleter might suggest <tt>System</tt>.</p> <p>For this kind of completion to work, QCompleter needs to be able to split the path into a list of strings that are matched at each level. For <tt>C:\Windows\Sy</tt>, it needs to be split as "C:", "Windows" and "Sy". The default implementation of <a href="qcompleter.html#splitPath">splitPath</a>(), splits the <a href="qcompleter.html#completionPrefix-prop">completionPrefix</a> using <a href="qdir.html#separator">QDir.separator</a>() if the model is a <a href="qfilesystemmodel.html">QFileSystemModel</a>.</p> <p>To provide completions, QCompleter needs to know the path from an index. This is provided by <a href="qcompleter.html#pathFromIndex">pathFromIndex</a>(). The default implementation of <a href="qcompleter.html#pathFromIndex">pathFromIndex</a>(), returns the data for the <a href="qt.html#ItemDataRole-enum">edit role</a> for list models and the absolute file path if the mode is a <a href="qfilesystemmodel.html">QFileSystemModel</a>.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="CompletionMode-enum" />QCompleter.CompletionMode</h3><p>This enum specifies how completions are provided to the user.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QCompleter.PopupCompletion</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">Current completions are displayed in a popup window.</td> </tr> <tr> <td class="topAlign"><tt>QCompleter.InlineCompletion</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">Completions appear inline (as selected text).</td> </tr> <tr> <td class="topAlign"> <tt>QCompleter.UnfilteredPopupCompletion</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">All possible completions are displayed in a popup window with the most likely suggestion indicated as current.</td> </tr> </table> <p><b>See also</b> <a href="qcompleter.html#completionMode-prop">setCompletionMode</a>().</p> <h3 class="fn"><a name="ModelSorting-enum" />QCompleter.ModelSorting</h3><p>This enum specifies how the items in the model are sorted.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QCompleter.UnsortedModel</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">The model is unsorted.</td> </tr> <tr> <td class="topAlign"> <tt>QCompleter.CaseSensitivelySortedModel</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">The model is sorted case sensitively.</td> </tr> <tr> <td class="topAlign"> <tt>QCompleter.CaseInsensitivelySortedModel</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">The model is sorted case insensitively.</td> </tr> </table> <p><b>See also</b> <a href="qcompleter.html#modelSorting-prop">setModelSorting</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QCompleter" />QCompleter.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument</p><p>Constructs a completer object with the given <i>parent</i>.</p> <h3 class="fn"><a name="QCompleter-2" />QCompleter.__init__ (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a> <i>model</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a completer object with the given <i>parent</i> that provides completions from the specified <i>model</i>.</p> <h3 class="fn"><a name="QCompleter-3" />QCompleter.__init__ (<i>self</i>, QStringList <i>list</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qcompleter.html">QCompleter</a> object with the given <i>parent</i> that uses the specified <i>list</i> as a source of possible completions.</p> <h3 class="fn"><a name="caseSensitivity" /><a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> QCompleter.caseSensitivity (<i>self</i>)</h3><h3 class="fn"><a name="complete" />QCompleter.complete (<i>self</i>, <a href="qrect.html">QRect</a> <i>rect</i> = QRect())</h3><p>This method is also a Qt slot with the C++ signature <tt>void complete(const QRect& = QRect())</tt>.</p><p>For <a href="qcompleter.html#CompletionMode-enum">QCompleter.PopupCompletion</a> and QCompletion.UnfilteredPopupCompletion modes, calling this function displays the popup displaying the current completions. By default, if <i>rect</i> is not specified, the popup is displayed on the bottom of the <a href="qcompleter.html#widget">widget</a>(). If <i>rect</i> is specified the popup is displayed on the left edge of the rectangle.</p> <p>For <a href="qcompleter.html#CompletionMode-enum">QCompleter.InlineCompletion</a> mode, the <a href="qcompleter.html#highlighted">highlighted</a>() signal is fired with the current completion.</p> <h3 class="fn"><a name="completionColumn" />int QCompleter.completionColumn (<i>self</i>)</h3><h3 class="fn"><a name="completionCount" />int QCompleter.completionCount (<i>self</i>)</h3><p>Returns the number of completions for the current prefix. For an unsorted model with a large number of items this can be expensive. Use <a href="qcompleter.html#setCurrentRow">setCurrentRow</a>() and <a href="qcompleter.html#currentCompletion">currentCompletion</a>() to iterate through all the completions.</p> <h3 class="fn"><a name="completionMode" /><a href="qcompleter.html#CompletionMode-enum">CompletionMode</a> QCompleter.completionMode (<i>self</i>)</h3><h3 class="fn"><a name="completionModel" /><a href="qabstractitemmodel.html">QAbstractItemModel</a> QCompleter.completionModel (<i>self</i>)</h3><p>Returns the completion model. The completion model is a read-only list model that contains all the possible matches for the current completion prefix. The completion model is auto-updated to reflect the current completions.</p> <p><b>Note:</b> The return value of this function is defined to be an <a href="qabstractitemmodel.html">QAbstractItemModel</a> purely for generality. This actual kind of model returned is an instance of an <a href="qabstractproxymodel.html">QAbstractProxyModel</a> subclass.</p> <p><b>See also</b> <a href="qcompleter.html#completionPrefix-prop">completionPrefix</a> and <a href="qcompleter.html#model">model</a>().</p> <h3 class="fn"><a name="completionPrefix" />QString QCompleter.completionPrefix (<i>self</i>)</h3><h3 class="fn"><a name="completionRole" />int QCompleter.completionRole (<i>self</i>)</h3><h3 class="fn"><a name="currentCompletion" />QString QCompleter.currentCompletion (<i>self</i>)</h3><p>Returns the current completion string. This includes the <a href="qcompleter.html#completionPrefix-prop">completionPrefix</a>. When used alongside <a href="qcompleter.html#setCurrentRow">setCurrentRow</a>(), it can be used to iterate through all the matches.</p> <p><b>See also</b> <a href="qcompleter.html#setCurrentRow">setCurrentRow</a>() and <a href="qcompleter.html#currentIndex">currentIndex</a>().</p> <h3 class="fn"><a name="currentIndex" /><a href="qmodelindex.html">QModelIndex</a> QCompleter.currentIndex (<i>self</i>)</h3><p>Returns the model index of the current completion in the <a href="qcompleter.html#completionModel">completionModel</a>().</p> <p><b>See also</b> <a href="qcompleter.html#setCurrentRow">setCurrentRow</a>(), <a href="qcompleter.html#currentCompletion">currentCompletion</a>(), and <a href="qcompleter.html#model">model</a>().</p> <h3 class="fn"><a name="currentRow" />int QCompleter.currentRow (<i>self</i>)</h3><p>Returns the current row.</p> <p><b>See also</b> <a href="qcompleter.html#setCurrentRow">setCurrentRow</a>().</p> <h3 class="fn"><a name="event" />bool QCompleter.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p> <h3 class="fn"><a name="eventFilter" />bool QCompleter.eventFilter (<i>self</i>, <a href="qobject.html">QObject</a> <i>o</i>, <a href="qevent.html">QEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qobject.html#eventFilter">QObject.eventFilter</a>().</p> <h3 class="fn"><a name="maxVisibleItems" />int QCompleter.maxVisibleItems (<i>self</i>)</h3><h3 class="fn"><a name="model" /><a href="qabstractitemmodel.html">QAbstractItemModel</a> QCompleter.model (<i>self</i>)</h3><p>Returns the model that provides completion strings.</p> <p><b>See also</b> <a href="qcompleter.html#setModel">setModel</a>() and <a href="qcompleter.html#completionModel">completionModel</a>().</p> <h3 class="fn"><a name="modelSorting" /><a href="qcompleter.html#ModelSorting-enum">ModelSorting</a> QCompleter.modelSorting (<i>self</i>)</h3><h3 class="fn"><a name="pathFromIndex" />QString QCompleter.pathFromIndex (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns the path for the given <i>index</i>. The completer object uses this to obtain the completion text from the underlying model.</p> <p>The default implementation returns the <a href="qt.html#ItemDataRole-enum">edit role</a> of the item for list models. It returns the absolute file path if the model is a <a href="qfilesystemmodel.html">QFileSystemModel</a>.</p> <p><b>See also</b> <a href="qcompleter.html#splitPath">splitPath</a>().</p> <h3 class="fn"><a name="popup" /><a href="qabstractitemview.html">QAbstractItemView</a> QCompleter.popup (<i>self</i>)</h3><p>Returns the popup used to display completions.</p> <p><b>See also</b> <a href="qcompleter.html#setPopup">setPopup</a>().</p> <h3 class="fn"><a name="setCaseSensitivity" />QCompleter.setCaseSensitivity (<i>self</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>caseSensitivity</i>)</h3><h3 class="fn"><a name="setCompletionColumn" />QCompleter.setCompletionColumn (<i>self</i>, int <i>column</i>)</h3><h3 class="fn"><a name="setCompletionMode" />QCompleter.setCompletionMode (<i>self</i>, <a href="qcompleter.html#CompletionMode-enum">CompletionMode</a> <i>mode</i>)</h3><h3 class="fn"><a name="setCompletionPrefix" />QCompleter.setCompletionPrefix (<i>self</i>, QString <i>prefix</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setCompletionPrefix(const QString&)</tt>.</p><h3 class="fn"><a name="setCompletionRole" />QCompleter.setCompletionRole (<i>self</i>, int <i>role</i>)</h3><h3 class="fn"><a name="setCurrentRow" />bool QCompleter.setCurrentRow (<i>self</i>, int <i>row</i>)</h3><p>Sets the current row to the <i>row</i> specified. Returns true if successful; otherwise returns false.</p> <p>This function may be used along with <a href="qcompleter.html#currentCompletion">currentCompletion</a>() to iterate through all the possible completions.</p> <p><b>See also</b> <a href="qcompleter.html#currentRow">currentRow</a>(), <a href="qcompleter.html#currentCompletion">currentCompletion</a>(), and <a href="qcompleter.html#completionCount">completionCount</a>().</p> <h3 class="fn"><a name="setMaxVisibleItems" />QCompleter.setMaxVisibleItems (<i>self</i>, int <i>maxItems</i>)</h3><h3 class="fn"><a name="setModel" />QCompleter.setModel (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a> <i>c</i>)</h3><p>Sets the model which provides completions to <i>model</i>. The <i>model</i> can be list model or a tree model. If a model has been already previously set and it has the <a href="qcompleter.html">QCompleter</a> as its parent, it is deleted.</p> <p>For convenience, if <i>model</i> is a <a href="qfilesystemmodel.html">QFileSystemModel</a>, <a href="qcompleter.html">QCompleter</a> switches its <a href="qcompleter.html#caseSensitivity-prop">caseSensitivity</a> to <a href="qt.html#CaseSensitivity-enum">Qt.CaseInsensitive</a> on Windows and <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> on other platforms.</p> <p><b>See also</b> <a href="qcompleter.html#completionModel">completionModel</a>(), <a href="qcompleter.html#modelSorting-prop">modelSorting</a>, and <a href="qcompleter.html#handling-tree-models">Handling Tree Models</a>.</p> <h3 class="fn"><a name="setModelSorting" />QCompleter.setModelSorting (<i>self</i>, <a href="qcompleter.html#ModelSorting-enum">ModelSorting</a> <i>sorting</i>)</h3><h3 class="fn"><a name="setPopup" />QCompleter.setPopup (<i>self</i>, <a href="qabstractitemview.html">QAbstractItemView</a> <i>popup</i>)</h3><p>The <i>popup</i> argument has it's ownership transferred to Qt.</p><p>Sets the popup used to display completions to <i>popup</i>. <a href="qcompleter.html">QCompleter</a> takes ownership of the view.</p> <p>A <a href="qlistview.html">QListView</a> is automatically created when the <a href="qcompleter.html#completionMode-prop">completionMode</a>() is set to <a href="qcompleter.html#CompletionMode-enum">QCompleter.PopupCompletion</a> or <a href="qcompleter.html#CompletionMode-enum">QCompleter.UnfilteredPopupCompletion</a>. The default popup displays the <a href="qcompleter.html#completionColumn-prop">completionColumn</a>().</p> <p>Ensure that this function is called before the view settings are modified. This is required since view's properties may require that a model has been set on the view (for example, hiding columns in the view requires a model to be set on the view).</p> <p><b>See also</b> <a href="qcompleter.html#popup">popup</a>().</p> <h3 class="fn"><a name="setWidget" />QCompleter.setWidget (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>widget</i>)</h3><p>The <i>widget</i> argument has it's ownership transferred to Qt.</p><p>Sets the widget for which completion are provided for to <i>widget</i>. This function is automatically called when a <a href="qcompleter.html">QCompleter</a> is set on a <a href="qlineedit.html">QLineEdit</a> using <a href="qlineedit.html#setCompleter">QLineEdit.setCompleter</a>() or on a <a href="qcombobox.html">QComboBox</a> using <a href="qcombobox.html#setCompleter">QComboBox.setCompleter</a>(). The widget needs to be set explicitly when providing completions for custom widgets.</p> <p><b>See also</b> <a href="qcompleter.html#widget">widget</a>(), <a href="qcompleter.html#setModel">setModel</a>(), and <a href="qcompleter.html#setPopup">setPopup</a>().</p> <h3 class="fn"><a name="setWrapAround" />QCompleter.setWrapAround (<i>self</i>, bool <i>wrap</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setWrapAround(bool)</tt>.</p><h3 class="fn"><a name="splitPath" />QStringList QCompleter.splitPath (<i>self</i>, QString <i>path</i>)</h3><p>Splits the given <i>path</i> into strings that are used to match at each level in the <a href="qcompleter.html#model">model</a>().</p> <p>The default implementation of splitPath() splits a file system path based on <a href="qdir.html#separator">QDir.separator</a>() when the sourceModel() is a <a href="qfilesystemmodel.html">QFileSystemModel</a>.</p> <p>When used with list models, the first item in the returned list is used for matching.</p> <p><b>See also</b> <a href="qcompleter.html#pathFromIndex">pathFromIndex</a>() and <a href="qcompleter.html#handling-tree-models">Handling Tree Models</a>.</p> <h3 class="fn"><a name="widget" /><a href="qwidget.html">QWidget</a> QCompleter.widget (<i>self</i>)</h3><p>Returns the widget for which the completer object is providing completions.</p> <p><b>See also</b> <a href="qcompleter.html#setWidget">setWidget</a>().</p> <h3 class="fn"><a name="wrapAround" />bool QCompleter.wrapAround (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="activated" />void activated (const QString&)</h3><p>This is the default overload of this signal.</p><p>This signal is sent when an item in the <a href="qcompleter.html#popup">popup</a>() is activated by the user (by clicking or pressing return). The item's <i>text</i> is given.</p> <h3 class="fn"><a name="activated-2" />void activated (const QModelIndex&)</h3><p>This signal is sent when an item in the <a href="qcompleter.html#popup">popup</a>() is activated by the user. (by clicking or pressing return). The item's <i>index</i> in the <a href="qcompleter.html#completionModel">completionModel</a>() is given.</p> <h3 class="fn"><a name="highlighted" />void highlighted (const QString&)</h3><p>This is the default overload of this signal.</p><p>This signal is sent when an item in the <a href="qcompleter.html#popup">popup</a>() is highlighted by the user. It is also sent if <a href="qcompleter.html#complete">complete</a>() is called with the <a href="qcompleter.html#completionMode-prop">completionMode</a>() set to <a href="qcompleter.html#CompletionMode-enum">QCompleter.InlineCompletion</a>. The item's <i>text</i> is given.</p> <h3 class="fn"><a name="highlighted-2" />void highlighted (const QModelIndex&)</h3><p>This signal is sent when an item in the <a href="qcompleter.html#popup">popup</a>() is highlighted by the user. It is also sent if <a href="qcompleter.html#complete">complete</a>() is called with the <a href="qcompleter.html#completionMode-prop">completionMode</a>() set to <a href="qcompleter.html#CompletionMode-enum">QCompleter.InlineCompletion</a>. The item's <i>index</i> in the <a href="qcompleter.html#completionModel">completionModel</a>() is given.</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>