File: qcompleter.html

package info (click to toggle)
python-qt4 4.11.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 40,148 kB
  • ctags: 6,150
  • sloc: python: 125,936; cpp: 12,628; xml: 292; makefile: 259; php: 27; sh: 2
file content (337 lines) | stat: -rw-r--r-- 32,376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <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&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qcompleter.html#QCompleter-2">__init__</a></b> (<i>self</i>, QAbstractItemModel&#160;<i>model</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qcompleter.html#QCompleter-3">__init__</a></b> (<i>self</i>, QStringList&#160;<i>list</i>, QObject&#160;<i>parent</i>&#160;=&#160;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&#160;<i>rect</i>&#160;=&#160;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&#160;<i>o</i>, QEvent&#160;<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&#160;<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&#160;<i>caseSensitivity</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionColumn">setCompletionColumn</a></b> (<i>self</i>, int&#160;<i>column</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionMode">setCompletionMode</a></b> (<i>self</i>, CompletionMode&#160;<i>mode</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionPrefix">setCompletionPrefix</a></b> (<i>self</i>, QString&#160;<i>prefix</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setCompletionRole">setCompletionRole</a></b> (<i>self</i>, int&#160;<i>role</i>)</li><li><div class="fn" />bool <b><a href="qcompleter.html#setCurrentRow">setCurrentRow</a></b> (<i>self</i>, int&#160;<i>row</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setMaxVisibleItems">setMaxVisibleItems</a></b> (<i>self</i>, int&#160;<i>maxItems</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setModel">setModel</a></b> (<i>self</i>, QAbstractItemModel&#160;<i>c</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setModelSorting">setModelSorting</a></b> (<i>self</i>, ModelSorting&#160;<i>sorting</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setPopup">setPopup</a></b> (<i>self</i>, QAbstractItemView&#160;<i>popup</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setWidget">setWidget</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>)</li><li><div class="fn" /><b><a href="qcompleter.html#setWrapAround">setWrapAround</a></b> (<i>self</i>, bool&#160;<i>wrap</i>)</li><li><div class="fn" />QStringList <b><a href="qcompleter.html#splitPath">splitPath</a></b> (<i>self</i>, QString&#160;<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&amp;)</li><li><div class="fn" />void <b><a href="qcompleter.html#activated-2">activated</a></b> (const QModelIndex&amp;)</li><li><div class="fn" />void <b><a href="qcompleter.html#highlighted">highlighted</a></b> (const QString&amp;)</li><li><div class="fn" />void <b><a href="qcompleter.html#highlighted-2">highlighted</a></b> (const QModelIndex&amp;)</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">&lt;</span><span class="operator">&lt;</span> <span class="string">"alpha"</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">"omega"</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">"omicron"</span> <span class="operator">&lt;</span><span class="operator">&lt;</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">&gt;</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">&gt;</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">&gt;</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">&gt;</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">&gt;</span>setCurrentRow(i); i<span class="operator">+</span><span class="operator">+</span>)
     <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> completer<span class="operator">-</span><span class="operator">&gt;</span><a href="qcompleter.html#currentCompletion">currentCompletion</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">" is match number "</span> <span class="operator">&lt;</span><span class="operator">&lt;</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>&#160;<i>parent</i>&#160;=&#160;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>.</p>


<h3 class="fn"><a name="QCompleter-2" />QCompleter.__init__ (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a>&#160;<i>model</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;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&#160;<i>list</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;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>&#160;<i>rect</i>&#160;=&#160;QRect())</h3><p>This method is also a Qt slot with the C++ signature <tt>void complete(const QRect&amp; = 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>&#160;<i>o</i>, <a href="qevent.html">QEvent</a>&#160;<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>&#160;<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>&#160;<i>caseSensitivity</i>)</h3><h3 class="fn"><a name="setCompletionColumn" />QCompleter.setCompletionColumn (<i>self</i>, int&#160;<i>column</i>)</h3><h3 class="fn"><a name="setCompletionMode" />QCompleter.setCompletionMode (<i>self</i>, <a href="qcompleter.html#CompletionMode-enum">CompletionMode</a>&#160;<i>mode</i>)</h3><h3 class="fn"><a name="setCompletionPrefix" />QCompleter.setCompletionPrefix (<i>self</i>, QString&#160;<i>prefix</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setCompletionPrefix(const QString&amp;)</tt>.</p><h3 class="fn"><a name="setCompletionRole" />QCompleter.setCompletionRole (<i>self</i>, int&#160;<i>role</i>)</h3><h3 class="fn"><a name="setCurrentRow" />bool QCompleter.setCurrentRow (<i>self</i>, int&#160;<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&#160;<i>maxItems</i>)</h3><h3 class="fn"><a name="setModel" />QCompleter.setModel (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a>&#160;<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>&#160;<i>sorting</i>)</h3><h3 class="fn"><a name="setPopup" />QCompleter.setPopup (<i>self</i>, <a href="qabstractitemview.html">QAbstractItemView</a>&#160;<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>&#160;<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&#160;<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&#160;<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&amp;)</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&amp;)</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&amp;)</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&amp;)</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&#160;4.11.4 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt&#160;4.8.7</td></tr></table></div></address></body></html>