itom
Loading...
Searching...
No Matches
Completer Class Reference

#include <completer.h>

Inheritance diagram for Completer:

Public Types

enum  ModelFiltering { FilterStartsWith =0 , FilterContains , FilterWordStartsWith }
 

Public Member Functions

 Completer (QObject *parent=0)
 
 Completer (QAbstractItemModel *model, QObject *parent=0)
 
 Completer (const QStringList &list, QObject *parent=0)
 
ModelFiltering modelFiltering () const
 
void setModelFiltering (ModelFiltering filter)
 
virtual QStringList splitPath (const QString &s) const
 
QAbstractItemModel * sourceModel () const
 
void setSourceModel (QAbstractItemModel *model)
 

Protected Attributes

QScopedPointer< CompleterPrivated_ptr
 

Properties

ModelFiltering modelFiltering
 

Private Member Functions

 Q_DECLARE_PRIVATE (Completer)
 
 Q_DISABLE_COPY (Completer)
 

Detailed Description

Completer is a QCompleter that allows different way of filtering the model, not just by filtering strings that start with the

See also
completionPrefix (default behavior). Completer is a bit hackish as it reimplements a methods (splitPath) from QCompleter in a way that is not intended. Disclaimer, it might not work in all contexts, but seems to work fine with a QLineEdit. e.g.: QStringList model; model << "toto tata tutu"; model << "tata toto tutu"; Completer completer(model); completer.setModelFiltering(Completer::FilterWordStartsWith); QLineEdit lineEdit; lineEdit.setCompleter(&completer); ... If the user types "ta", both entries will show up in the completer If the user types "ot", no entries will show up in the completer however using
FilterContains would have shown both.

Member Function Documentation

◆ sourceModel()

QAbstractItemModel * Completer::sourceModel ( ) const

Completer::model() might return a filtered model (QSortFilterAbstractModel) different from the one that was set. QCompleter::setModel should not be used and setSourceModel used instead.

Property Documentation

◆ modelFiltering

ModelFiltering Completer::modelFiltering
readwrite

FilterStartsWith is the default behavior (same as QCompleter).The completer filters out strings that don't start with

See also
completionPrefix FilterContains is the most permissive filter, the completer filters out only strings that don't contain the characters from
completionPrefix FilterWordStartsWith is useful when strings contain space separated words and
completionPrefix applies to the beginning of any of the words in the string.

The documentation for this class was generated from the following files: