Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 3252

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qcompleter.cpp -->
  <title>QCompleter Class | Qt Widgets 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QCompleter</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#basic-usage">Basic Usage</a></li>
<li class="level2"><a href="#iterating-through-completions">Iterating Through Completions</a></li>
<li class="level2"><a href="#the-completion-model">The Completion Model</a></li>
<li class="level2"><a href="#handling-tree-models">Handling Tree Models</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QCompleter Class</h1>
<!-- $$$QCompleter-brief -->
<p>The <a href="qcompleter.html">QCompleter</a> class provides completions based on an item model. <a href="#details">More...</a></p>
<!-- @@@QCompleter -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QCompleter&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qobject.html">QObject</a></td></tr></table></div><ul>
<li><a href="qcompleter-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#CompletionMode-enum">CompletionMode</a></b> { PopupCompletion, InlineCompletion, UnfilteredPopupCompletion }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#ModelSorting-enum">ModelSorting</a></b> { UnsortedModel, CaseSensitivelySortedModel, CaseInsensitivelySortedModel }</td></tr>
</table></div>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<div class="table"><table class="propsummary">
<tr><td class="topAlign"><ul>
<li class="fn"><b><a href="qcompleter.html#caseSensitivity-prop">caseSensitivity</a></b> : Qt::CaseSensitivity</li>
<li class="fn"><b><a href="qcompleter.html#completionColumn-prop">completionColumn</a></b> : int</li>
<li class="fn"><b><a href="qcompleter.html#completionMode-prop">completionMode</a></b> : CompletionMode</li>
<li class="fn"><b><a href="qcompleter.html#completionPrefix-prop">completionPrefix</a></b> : QString</li>
<li class="fn"><b><a href="qcompleter.html#completionRole-prop">completionRole</a></b> : int</li>
</ul></td><td class="topAlign"><ul>
<li class="fn"><b><a href="qcompleter.html#filterMode-prop">filterMode</a></b> : Qt::MatchFlags</li>
<li class="fn"><b><a href="qcompleter.html#maxVisibleItems-prop">maxVisibleItems</a></b> : int</li>
<li class="fn"><b><a href="qcompleter.html#modelSorting-prop">modelSorting</a></b> : ModelSorting</li>
<li class="fn"><b><a href="qcompleter.html#wrapAround-prop">wrapAround</a></b> : bool</li>
</ul>
</td></tr>
</table></div>
<ul>
<li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#QCompleter">QCompleter</a></b>(QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#QCompleter-1">QCompleter</a></b>(QAbstractItemModel *<i>model</i>, QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#QCompleter-2">QCompleter</a></b>(const QStringList &amp;<i>list</i>, QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#dtor.QCompleter">~QCompleter</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::CaseSensitivity </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#caseSensitivity-prop">caseSensitivity</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionColumn-prop">completionColumn</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionCount">completionCount</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> CompletionMode </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionMode-prop">completionMode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractItemModel *</td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionModel">completionModel</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionPrefix-prop">completionPrefix</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionRole-prop">completionRole</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#currentCompletion">currentCompletion</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#currentIndex">currentIndex</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#currentRow">currentRow</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::MatchFlags </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#filterMode-prop">filterMode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#maxVisibleItems-prop">maxVisibleItems</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractItemModel *</td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#model">model</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> ModelSorting </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#modelSorting-prop">modelSorting</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#pathFromIndex">pathFromIndex</a></b>(const QModelIndex &amp;<i>index</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractItemView *</td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#popup">popup</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#caseSensitivity-prop">setCaseSensitivity</a></b>(Qt::CaseSensitivity <i>caseSensitivity</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionColumn-prop">setCompletionColumn</a></b>(int <i>column</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionMode-prop">setCompletionMode</a></b>(CompletionMode <i>mode</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionRole-prop">setCompletionRole</a></b>(int <i>role</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#setCurrentRow">setCurrentRow</a></b>(int <i>row</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#filterMode-prop">setFilterMode</a></b>(Qt::MatchFlags <i>filterMode</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#maxVisibleItems-prop">setMaxVisibleItems</a></b>(int <i>maxItems</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#setModel">setModel</a></b>(QAbstractItemModel *<i>model</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#modelSorting-prop">setModelSorting</a></b>(ModelSorting <i>sorting</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#setPopup">setPopup</a></b>(QAbstractItemView *<i>popup</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#setWidget">setWidget</a></b>(QWidget *<i>widget</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QStringList </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#splitPath">splitPath</a></b>(const QString &amp;<i>path</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget *</td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#widget">widget</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#wrapAround-prop">wrapAround</a></b>() const</td></tr>
</table></div>
<ul>
<li class="fn">32 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#complete">complete</a></b>(const QRect &amp;<i>rect</i> = QRect())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#completionPrefix-prop">setCompletionPrefix</a></b>(const QString &amp;<i>prefix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#wrapAround-prop">setWrapAround</a></b>(bool <i>wrap</i>)</td></tr>
</table></div>
<ul>
<li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#activated">activated</a></b>(const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#activated-1">activated</a></b>(const QModelIndex &amp;<i>index</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#highlighted">highlighted</a></b>(const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#highlighted-1">highlighted</a></b>(const QModelIndex &amp;<i>index</i>)</td></tr>
</table></div>
<ul>
<li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#event">event</a></b>(QEvent *<i>ev</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qcompleter.html#eventFilter">eventFilter</a></b>(QObject *<i>o</i>, QEvent *<i>e</i>)</td></tr>
</table></div>
<ul>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li>
<li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
<li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QCompleter-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qcompleter.html">QCompleter</a> class provides completions based on an item model.</p>
<p>You can use <a href="qcompleter.html">QCompleter</a> 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, <a href="qcompleter.html">QCompleter</a> suggests possible ways of completing the word, based on a word list. The word list is provided as a <a href="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a>. (For simple applications, where the word list is static, you can pass a <a href="../qtcore/qstringlist.html">QStringList</a> to <a href="qcompleter.html">QCompleter</a>'s constructor.)</p>
<a name="basic-usage"></a>
<h3 >Basic Usage</h3>
<p>A <a href="qcompleter.html">QCompleter</a> 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="../qtcore/qstringlist.html">QStringList</a></span> wordList;
  wordList <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;alpha&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;omega&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;omicron&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;zeta&quot;</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"><a href="qcompleter.html#QCompleter">QCompleter</a></span> <span class="operator">*</span>completer <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span>(wordList<span class="operator">,</span> <span class="keyword">this</span>);
  completer<span class="operator">-</span><span class="operator">&gt;</span>setCaseSensitivity(<span class="type"><a href="../qtcore/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"><a href="qcompleter.html#QCompleter">QCompleter</a></span> <span class="operator">*</span>completer <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span>(<span class="keyword">this</span>);
  completer<span class="operator">-</span><span class="operator">&gt;</span>setModel(<span class="keyword">new</span> <span class="type"><a href="qfilesystemmodel.html">QFileSystemModel</a></span>(completer));
  lineEdit<span class="operator">-</span><span class="operator">&gt;</span>setCompleter(completer);

</pre>
<p>To set the model on which <a href="qcompleter.html">QCompleter</a> should operate, call <a href="qcompleter.html#setModel">setModel</a>(). By default, <a href="qcompleter.html">QCompleter</a> will attempt to match the <a href="qcompleter.html#completionPrefix-prop">completion prefix</a> (i.e&#x2e;, the word that the user has started typing) against the <a href="../qtcore/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 <a href="qcompleter.html">QCompleter</a> can then use binary search instead of linear search. The binary search only works when the <a href="qcompleter.html#filterMode-prop">filterMode</a> is <a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchStartsWith</a>.</p>
<p>The model can be a <a href="../qtcore/qabstractlistmodel.html">list model</a>, a <a href="../qtcore/qabstracttablemodel.html">table model</a>, or a <a href="../qtcore/qabstractitemmodel.html">tree model</a>. Completion on tree models is slightly more involved and is covered in the <a href="qcompleter.html#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 name="iterating-through-completions"></a>
<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/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> completer<span class="operator">-</span><span class="operator">&gt;</span>currentCompletion() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot; is match number &quot;</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 name="the-completion-model"></a>
<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 name="handling-tree-models"></a>
<h3 >Handling Tree Models</h3>
<p><a href="qcompleter.html">QCompleter</a> 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 <code>C:\Wind</code>, <a href="qcompleter.html">QCompleter</a> might suggest <code>Windows</code> to complete the current path element. Similarly, if the current text is <code>C:\Windows\Sy</code>, <a href="qcompleter.html">QCompleter</a> might suggest <code>System</code>.</p>
<p>For this kind of completion to work, <a href="qcompleter.html">QCompleter</a> needs to be able to split the path into a list of strings that are matched at each level. For <code>C:\Windows\Sy</code>, it needs to be split as &quot;C:&quot;, &quot;Windows&quot; and &quot;Sy&quot;. The default implementation of <a href="qcompleter.html#splitPath">splitPath</a>(), splits the <a href="qcompleter.html#completionPrefix-prop">completionPrefix</a> using <a href="../qtcore/qdir.html#separator">QDir::separator</a>() if the model is a <a href="qfilesystemmodel.html">QFileSystemModel</a>.</p>
<p>To provide completions, <a href="qcompleter.html">QCompleter</a> 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="../qtcore/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>
</div>
<p><b>See also </b><a href="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a>, <a href="qlineedit.html">QLineEdit</a>, <a href="qcombobox.html">QComboBox</a>, and <a href="qtwidgets-tools-completer-example.html">Completer Example</a>.</p>
<!-- @@@QCompleter -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$CompletionMode$$$PopupCompletion$$$UnfilteredPopupCompletion$$$InlineCompletion -->
<h3 class="fn" id="CompletionMode-enum"><a name="CompletionMode-enum"></a>enum QCompleter::<span class="name">CompletionMode</span></h3>
<p>This enum specifies how completions are provided to the user.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QCompleter::PopupCompletion</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">Current completions are displayed in a popup window.</td></tr>
<tr><td class="topAlign"><code>QCompleter::InlineCompletion</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">Completions appear inline (as selected text).</td></tr>
<tr><td class="topAlign"><code>QCompleter::UnfilteredPopupCompletion</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">All possible completions are displayed in a popup window with the most likely suggestion indicated as current.</td></tr>
</table></div>
<p><b>See also </b><a href="qcompleter.html#completionMode-prop">setCompletionMode</a>().</p>
<!-- @@@CompletionMode -->
<!-- $$$ModelSorting$$$UnsortedModel$$$CaseSensitivelySortedModel$$$CaseInsensitivelySortedModel -->
<h3 class="fn" id="ModelSorting-enum"><a name="ModelSorting-enum"></a>enum QCompleter::<span class="name">ModelSorting</span></h3>
<p>This enum specifies how the items in the model are sorted.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QCompleter::UnsortedModel</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The model is unsorted.</td></tr>
<tr><td class="topAlign"><code>QCompleter::CaseSensitivelySortedModel</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The model is sorted case sensitively.</td></tr>
<tr><td class="topAlign"><code>QCompleter::CaseInsensitivelySortedModel</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">The model is sorted case insensitively.</td></tr>
</table></div>
<p><b>See also </b><a href="qcompleter.html#modelSorting-prop">setModelSorting</a>().</p>
<!-- @@@ModelSorting -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$caseSensitivity-prop$$$caseSensitivity$$$setCaseSensitivityQt::CaseSensitivity -->
<h3 class="fn" id="caseSensitivity-prop"><a name="caseSensitivity-prop"></a><span class="name">caseSensitivity</span> : <span class="type"><a href="../qtcore/qt.html#CaseSensitivity-enum">Qt::CaseSensitivity</a></span></h3>
<p>This property holds the case sensitivity of the matching</p>
<p>The default is <a href="../qtcore/qt.html#CaseSensitivity-enum">Qt::CaseSensitive</a>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::CaseSensitivity </td><td class="memItemRight bottomAlign"><span class="name"><b>caseSensitivity</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCaseSensitivity</b></span>(Qt::CaseSensitivity <i>caseSensitivity</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcompleter.html#completionColumn-prop">completionColumn</a>, <a href="qcompleter.html#completionRole-prop">completionRole</a>, and <a href="qcompleter.html#modelSorting-prop">modelSorting</a>.</p>
<!-- @@@caseSensitivity -->
<!-- $$$completionColumn-prop$$$completionColumn$$$setCompletionColumnint -->
<h3 class="fn" id="completionColumn-prop"><a name="completionColumn-prop"></a><span class="name">completionColumn</span> : <span class="type">int</span></h3>
<p>This property holds the column in the model in which completions are searched for.</p>
<p>If the <a href="qcompleter.html#popup">popup</a>() is a <a href="qlistview.html">QListView</a>, it is automatically setup to display this column.</p>
<p>By default, the match column is 0.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>completionColumn</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCompletionColumn</b></span>(int <i>column</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcompleter.html#completionRole-prop">completionRole</a> and <a href="qcompleter.html#caseSensitivity-prop">caseSensitivity</a>.</p>
<!-- @@@completionColumn -->
<!-- $$$completionMode-prop$$$completionMode$$$setCompletionModeCompletionMode -->
<h3 class="fn" id="completionMode-prop"><a name="completionMode-prop"></a><span class="name">completionMode</span> : <span class="type"><a href="qcompleter.html#CompletionMode-enum">CompletionMode</a></span></h3>
<p>how the completions are provided to the user</p>
<p>The default value is <a href="qcompleter.html#CompletionMode-enum">QCompleter::PopupCompletion</a>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> CompletionMode </td><td class="memItemRight bottomAlign"><span class="name"><b>completionMode</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCompletionMode</b></span>(CompletionMode <i>mode</i>)</td></tr>
</table></div>
<!-- @@@completionMode -->
<!-- $$$completionPrefix-prop$$$completionPrefix$$$setCompletionPrefixconstQString& -->
<h3 class="fn" id="completionPrefix-prop"><a name="completionPrefix-prop"></a><span class="name">completionPrefix</span> : <span class="type"><a href="../qtcore/qstring.html">QString</a></span></h3>
<p>This property holds the completion prefix used to provide completions.</p>
<p>The <a href="qcompleter.html#completionModel">completionModel</a>() is updated to reflect the list of possible matches for <i>prefix</i>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>completionPrefix</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCompletionPrefix</b></span>(const QString &amp;<i>prefix</i>)</td></tr>
</table></div>
<!-- @@@completionPrefix -->
<!-- $$$completionRole-prop$$$completionRole$$$setCompletionRoleint -->
<h3 class="fn" id="completionRole-prop"><a name="completionRole-prop"></a><span class="name">completionRole</span> : <span class="type">int</span></h3>
<p>This property holds the item role to be used to query the contents of items for matching.</p>
<p>The default role is <a href="../qtcore/qt.html#ItemDataRole-enum">Qt::EditRole</a>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>completionRole</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCompletionRole</b></span>(int <i>role</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcompleter.html#completionColumn-prop">completionColumn</a> and <a href="qcompleter.html#caseSensitivity-prop">caseSensitivity</a>.</p>
<!-- @@@completionRole -->
<!-- $$$filterMode-prop$$$filterMode$$$setFilterModeQt::MatchFlags -->
<h3 class="fn" id="filterMode-prop"><a name="filterMode-prop"></a><span class="name">filterMode</span> : <span class="type"><a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchFlags</a></span></h3>
<p>how the filtering is performed</p>
<p>If filterMode is set to <a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchStartsWith</a>, only those entries that start with the typed characters will be displayed. <a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchContains</a> will display the entries that contain the typed characters, and <a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchEndsWith</a> the ones that end with the typed characters.</p>
<p>Currently, only these three modes are implemented. Setting filterMode to any other <a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchFlag</a> will issue a warning, and no action will be performed.</p>
<p>The default mode is <a href="../qtcore/qt.html#MatchFlag-enum">Qt::MatchStartsWith</a>.</p>
<p>This property was introduced in  Qt 5.2.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::MatchFlags </td><td class="memItemRight bottomAlign"><span class="name"><b>filterMode</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setFilterMode</b></span>(Qt::MatchFlags <i>filterMode</i>)</td></tr>
</table></div>
<!-- @@@filterMode -->
<!-- $$$maxVisibleItems-prop$$$maxVisibleItems$$$setMaxVisibleItemsint -->
<h3 class="fn" id="maxVisibleItems-prop"><a name="maxVisibleItems-prop"></a><span class="name">maxVisibleItems</span> : <span class="type">int</span></h3>
<p>This property holds the maximum allowed size on screen of the completer, measured in items</p>
<p>By default, this property has a value of 7.</p>
<p>This property was introduced in  Qt 4.6.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>maxVisibleItems</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMaxVisibleItems</b></span>(int <i>maxItems</i>)</td></tr>
</table></div>
<!-- @@@maxVisibleItems -->
<!-- $$$modelSorting-prop$$$modelSorting$$$setModelSortingModelSorting -->
<h3 class="fn" id="modelSorting-prop"><a name="modelSorting-prop"></a><span class="name">modelSorting</span> : <span class="type"><a href="qcompleter.html#ModelSorting-enum">ModelSorting</a></span></h3>
<p>This property holds the way the model is sorted</p>
<p>By default, no assumptions are made about the order of the items in the model that provides the completions.</p>
<p>If the model's data for the <a href="qcompleter.html#completionColumn-prop">completionColumn</a>() and <a href="qcompleter.html#completionRole-prop">completionRole</a>() is sorted in ascending order, you can set this property to <a href="qcompleter.html#ModelSorting-enum">CaseSensitivelySortedModel</a> or <a href="qcompleter.html#ModelSorting-enum">CaseInsensitivelySortedModel</a>. On large models, this can lead to significant performance improvements because the completer object can then use a binary search algorithm instead of linear search algorithm.</p>
<p>The sort order (i.e ascending or descending order) of the model is determined dynamically by inspecting the contents of the model.</p>
<p><b>Note:</b> The performance improvements described above cannot take place when the completer's <a href="qcompleter.html#caseSensitivity-prop">caseSensitivity</a> is different to the case sensitivity used by the model's when sorting.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> ModelSorting </td><td class="memItemRight bottomAlign"><span class="name"><b>modelSorting</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setModelSorting</b></span>(ModelSorting <i>sorting</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcompleter.html#caseSensitivity-prop">setCaseSensitivity</a>() and <a href="qcompleter.html#ModelSorting-enum">QCompleter::ModelSorting</a>.</p>
<!-- @@@modelSorting -->
<!-- $$$wrapAround-prop$$$wrapAround$$$setWrapAroundbool -->
<h3 class="fn" id="wrapAround-prop"><a name="wrapAround-prop"></a><span class="name">wrapAround</span> : <span class="type">bool</span></h3>
<p>This property holds the completions wrap around when navigating through items</p>
<p>The default is true.</p>
<p>This property was introduced in  Qt 4.3.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>wrapAround</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setWrapAround</b></span>(bool <i>wrap</i>)</td></tr>
</table></div>
<!-- @@@wrapAround -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QCompleter[overload1]$$$QCompleterQObject* -->
<h3 class="fn" id="QCompleter"><a name="QCompleter"></a>QCompleter::<span class="name">QCompleter</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>Constructs a completer object with the given <i>parent</i>.</p>
<!-- @@@QCompleter -->
<!-- $$$QCompleter$$$QCompleterQAbstractItemModel*QObject* -->
<h3 class="fn" id="QCompleter-1"><a name="QCompleter-1"></a>QCompleter::<span class="name">QCompleter</span>(<span class="type"><a href="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a></span> *<i>model</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>Constructs a completer object with the given <i>parent</i> that provides completions from the specified <i>model</i>.</p>
<!-- @@@QCompleter -->
<!-- $$$QCompleter$$$QCompleterconstQStringList&QObject* -->
<h3 class="fn" id="QCompleter-2"><a name="QCompleter-2"></a>QCompleter::<span class="name">QCompleter</span>(const <span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> &amp;<i>list</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<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>
<!-- @@@QCompleter -->
<!-- $$$~QCompleter[overload1]$$$~QCompleter -->
<h3 class="fn" id="dtor.QCompleter"><a name="dtor.QCompleter"></a>QCompleter::<span class="name">~QCompleter</span>()</h3>
<p>Destroys the completer object.</p>
<!-- @@@~QCompleter -->
<!-- $$$activated[overload1]$$$activatedconstQString& -->
<h3 class="fn" id="activated"><a name="activated"></a><code>[signal] </code><span class="type">void</span> QCompleter::<span class="name">activated</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>)</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>text</i> is given.</p>
<p><b>Note:</b> Signal <i>activated</i> is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:<pre class="cpp">

  connect(completer<span class="operator">,</span> <span class="keyword">static_cast</span><span class="operator">&lt;</span><span class="type">void</span>(<span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span><span class="operator">*</span>)(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>)<span class="operator">&gt;</span>(<span class="operator">&amp;</span><span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span>activated)<span class="operator">,</span>
      <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>text){ <span class="comment">/* ... */</span> });

</pre>
<!-- @@@activated -->
<!-- $$$activated$$$activatedconstQModelIndex& -->
<h3 class="fn" id="activated-1"><a name="activated-1"></a><code>[signal] </code><span class="type">void</span> QCompleter::<span class="name">activated</span>(const <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> &amp;<i>index</i>)</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>
<p><b>Note:</b> Signal <i>activated</i> is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:<pre class="cpp">

  connect(completer<span class="operator">,</span> <span class="keyword">static_cast</span><span class="operator">&lt;</span><span class="type">void</span>(<span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span><span class="operator">*</span>)(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> <span class="operator">&amp;</span>)<span class="operator">&gt;</span>(<span class="operator">&amp;</span><span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span>activated)<span class="operator">,</span>
      <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> <span class="operator">&amp;</span>index){ <span class="comment">/* ... */</span> });

</pre>
<!-- @@@activated -->
<!-- $$$complete[overload1]$$$completeconstQRect& -->
<h3 class="fn" id="complete"><a name="complete"></a><code>[slot] </code><span class="type">void</span> QCompleter::<span class="name">complete</span>(const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &amp;<i>rect</i> = QRect())</h3>
<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>
<!-- @@@complete -->
<!-- $$$completionCount[overload1]$$$completionCount -->
<h3 class="fn" id="completionCount"><a name="completionCount"></a><span class="type">int</span> QCompleter::<span class="name">completionCount</span>() const</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>
<!-- @@@completionCount -->
<!-- $$$completionModel[overload1]$$$completionModel -->
<h3 class="fn" id="completionModel"><a name="completionModel"></a><span class="type"><a href="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a></span> *QCompleter::<span class="name">completionModel</span>() const</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="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a> purely for generality. This actual kind of model returned is an instance of an <a href="../qtcore/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>
<!-- @@@completionModel -->
<!-- $$$currentCompletion[overload1]$$$currentCompletion -->
<h3 class="fn" id="currentCompletion"><a name="currentCompletion"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QCompleter::<span class="name">currentCompletion</span>() const</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>
<!-- @@@currentCompletion -->
<!-- $$$currentIndex[overload1]$$$currentIndex -->
<h3 class="fn" id="currentIndex"><a name="currentIndex"></a><span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> QCompleter::<span class="name">currentIndex</span>() const</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>
<!-- @@@currentIndex -->
<!-- $$$currentRow[overload1]$$$currentRow -->
<h3 class="fn" id="currentRow"><a name="currentRow"></a><span class="type">int</span> QCompleter::<span class="name">currentRow</span>() const</h3>
<p>Returns the current row.</p>
<p><b>See also </b><a href="qcompleter.html#setCurrentRow">setCurrentRow</a>().</p>
<!-- @@@currentRow -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn" id="event"><a name="event"></a><code>[virtual protected] </code><span class="type">bool</span> QCompleter::<span class="name">event</span>(<span class="type"><a href="../qtcore/qevent.html">QEvent</a></span> *<i>ev</i>)</h3>
<p>Reimplemented from <a href="../qtcore/qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$eventFilter[overload1]$$$eventFilterQObject*QEvent* -->
<h3 class="fn" id="eventFilter"><a name="eventFilter"></a><code>[virtual protected] </code><span class="type">bool</span> QCompleter::<span class="name">eventFilter</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>o</i>, <span class="type"><a href="../qtcore/qevent.html">QEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="../qtcore/qobject.html#eventFilter">QObject::eventFilter</a>().</p>
<!-- @@@eventFilter -->
<!-- $$$highlighted[overload1]$$$highlightedconstQString& -->
<h3 class="fn" id="highlighted"><a name="highlighted"></a><code>[signal] </code><span class="type">void</span> QCompleter::<span class="name">highlighted</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>)</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>text</i> is given.</p>
<p><b>Note:</b> Signal <i>highlighted</i> is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:<pre class="cpp">

  connect(completer<span class="operator">,</span> <span class="keyword">static_cast</span><span class="operator">&lt;</span><span class="type">void</span>(<span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span><span class="operator">*</span>)(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>)<span class="operator">&gt;</span>(<span class="operator">&amp;</span><span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span>highlighted)<span class="operator">,</span>
      <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>text){ <span class="comment">/* ... */</span> });

</pre>
<!-- @@@highlighted -->
<!-- $$$highlighted$$$highlightedconstQModelIndex& -->
<h3 class="fn" id="highlighted-1"><a name="highlighted-1"></a><code>[signal] </code><span class="type">void</span> QCompleter::<span class="name">highlighted</span>(const <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> &amp;<i>index</i>)</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>
<p><b>Note:</b> Signal <i>highlighted</i> is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:<pre class="cpp">

  connect(completer<span class="operator">,</span> <span class="keyword">static_cast</span><span class="operator">&lt;</span><span class="type">void</span>(<span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span><span class="operator">*</span>)(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> <span class="operator">&amp;</span>)<span class="operator">&gt;</span>(<span class="operator">&amp;</span><span class="type"><a href="qcompleter.html#QCompleter">QCompleter</a></span><span class="operator">::</span>highlighted)<span class="operator">,</span>
      <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> <span class="operator">&amp;</span>index){ <span class="comment">/* ... */</span> });

</pre>
<!-- @@@highlighted -->
<!-- $$$model[overload1]$$$model -->
<h3 class="fn" id="model"><a name="model"></a><span class="type"><a href="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a></span> *QCompleter::<span class="name">model</span>() const</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>
<!-- @@@model -->
<!-- $$$pathFromIndex[overload1]$$$pathFromIndexconstQModelIndex& -->
<h3 class="fn" id="pathFromIndex"><a name="pathFromIndex"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QCompleter::<span class="name">pathFromIndex</span>(const <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> &amp;<i>index</i>) const</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="../qtcore/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>
<!-- @@@pathFromIndex -->
<!-- $$$popup[overload1]$$$popup -->
<h3 class="fn" id="popup"><a name="popup"></a><span class="type"><a href="qabstractitemview.html">QAbstractItemView</a></span> *QCompleter::<span class="name">popup</span>() const</h3>
<p>Returns the popup used to display completions.</p>
<p><b>See also </b><a href="qcompleter.html#setPopup">setPopup</a>().</p>
<!-- @@@popup -->
<!-- $$$setCurrentRow[overload1]$$$setCurrentRowint -->
<h3 class="fn" id="setCurrentRow"><a name="setCurrentRow"></a><span class="type">bool</span> QCompleter::<span class="name">setCurrentRow</span>(<span class="type">int</span> <i>row</i>)</h3>
<p>Sets the current row to the <i>row</i> specified. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</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>
<!-- @@@setCurrentRow -->
<!-- $$$setModel[overload1]$$$setModelQAbstractItemModel* -->
<h3 class="fn" id="setModel"><a name="setModel"></a><span class="type">void</span> QCompleter::<span class="name">setModel</span>(<span class="type"><a href="../qtcore/qabstractitemmodel.html">QAbstractItemModel</a></span> *<i>model</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="../qtcore/qt.html#CaseSensitivity-enum">Qt::CaseInsensitive</a> on Windows and <a href="../qtcore/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>
<!-- @@@setModel -->
<!-- $$$setPopup[overload1]$$$setPopupQAbstractItemView* -->
<h3 class="fn" id="setPopup"><a name="setPopup"></a><span class="type">void</span> QCompleter::<span class="name">setPopup</span>(<span class="type"><a href="qabstractitemview.html">QAbstractItemView</a></span> *<i>popup</i>)</h3>
<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>
<!-- @@@setPopup -->
<!-- $$$setWidget[overload1]$$$setWidgetQWidget* -->
<h3 class="fn" id="setWidget"><a name="setWidget"></a><span class="type">void</span> QCompleter::<span class="name">setWidget</span>(<span class="type"><a href="qwidget.html">QWidget</a></span> *<i>widget</i>)</h3>
<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>
<!-- @@@setWidget -->
<!-- $$$splitPath[overload1]$$$splitPathconstQString& -->
<h3 class="fn" id="splitPath"><a name="splitPath"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> QCompleter::<span class="name">splitPath</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>path</i>) const</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="../qtcore/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>
<!-- @@@splitPath -->
<!-- $$$widget[overload1]$$$widget -->
<h3 class="fn" id="widget"><a name="widget"></a><span class="type"><a href="qwidget.html">QWidget</a></span> *QCompleter::<span class="name">widget</span>() const</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>
<!-- @@@widget -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>