Questions tagged [qcompleter]

A QCompleter is a class from the Qt toolkit which provides completions based on an item model.

QCompleter can be set to provide auto-completion for any widget.

A simple example of using the QCompleter will look like this:

//this will contain the words for autocompletion.
QStringList words;
//Let's populate it:
words << "hello" << "word" << "this" << "is" << "qt" << "auto-completer";
//We will be using auto-completer for a QLineEdit
QLineEdit * l = new QLineEdit();
//Creating the QCompleter, and giving it the word list
QCompleter * completer = new QCompleter( words );
//Setting the case sensivity
completer->setCaseSensitivity( Qt::CaseInsensitive );
//Assigning the completer to the LineEdit
l->setCompleter( completer );
//And finally showing the edit.
l->show();

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

122 questions
24
votes
8 answers

QCompleter Custom Completion Rules

I'm using Qt4.6 and I have a QComboBox with a QCompleter in it. The usual functionality is to provide completion hints (these can be in a dropdown rather than inline - which is my usage) based on a prefix. For example, given chicken soup chilli…
jcuenod
  • 55,835
  • 14
  • 65
  • 102
9
votes
2 answers

How can I customize the QCompleter popup window in PyQt?

I have a few things for a QLineEdit's QCompleter I'm interested in customizing. I want to make it behave similar to the address / search bar in Chrome. How can I limit the number of rows that are displayed? For example, even if there are 15…
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
8
votes
3 answers

How to update QCompleter's model dynamically

I use QCompleter with QLineEdit, and I want to update QCompleter's model dynamically. i.e. the model's contents are updated according to QLineEdit's text. 1) mdict.h #include class QLineEdit; class QCompleter; class…
hu.
  • 131
  • 1
  • 9
5
votes
3 answers

Qt QCompleter multiple matches

I am trying to make QCompleter match several equivalent options which are separated with commas. There seemingly is no easy way to do that, but one line of QCompleter reference caught my attention, describing function QCompleter::splitPath: "When…
max
  • 51
  • 1
  • 2
4
votes
1 answer

Overriding QCompleter popup position

There have been similar questions asked about overriding the QCompleter popup position but i'll still not found a working solution. I simply want to move the popup down around 5px (I have some specific styling requirements) I've tried subclassing a…
Michael B
  • 153
  • 4
  • 15
4
votes
1 answer

How to use PyQt5 QCompleter for code completion

I want to create a QLineEdit field with basic code completion capability, but so far whenever I select an attribute of an item item.attr, the item. is replaced by attr rather than inserting attr after item.. Furthermore if that attr has…
Aaron
  • 10,133
  • 1
  • 24
  • 40
4
votes
1 answer

QCompleter on QLineEdit for parts of the inserted text

I made a QLineEdit for reading an infix maths expression. Operators are limited to the +-*/ and brackets. Values can be numeric or a variable name representing a numeric value. I want to autocomplete for variable names. The problem is that…
Mark Ang
  • 149
  • 1
  • 11
4
votes
2 answers

auto select first proposition of QCompleter in PopupCompletion mode

I didn't manage to select the first item of the completer when the popup is displayed in PopupCompletion mode. My current code that doesnt work: completer->setCompletionPrefix(text); QItemSelectionModel* sm = new…
Antoine
  • 910
  • 1
  • 9
  • 26
4
votes
1 answer

Globbing input with QCompleter?

I've implemented a standard PyQt QCompleter within a QLineEdit, the guts of which are: self.cam_completer = QtGui.QCompleter( self.cameras, self ) self.cam_completer.setCaseSensitivity( 0 ) self.cam_completer.setCompletionMode( 2…
3
votes
1 answer

How to disable scientific notation in QCompleter?

I have a table with some records that are keyed using a very large number as the primary key. I have code similar to the following which uses QCompleter to autocomplete lookups in this table. It works, but the displayed completions are formatted…
Lmwangi
  • 2,486
  • 1
  • 19
  • 26
3
votes
1 answer

PyQt QSortFilterProxyModel index from wrong model passed to mapToSource?

I want to get the integer stored in [(1, 'cb'), (3, 'cd'), (7, 'ca'), (11, 'aa'), (22, 'bd')] when I select the drop down auto complete item. Because I used a QSortFilterProxyModel, when using down key to select the item, the index is from the…
Shuman
  • 3,914
  • 8
  • 42
  • 65
3
votes
0 answers

PySide QT completer more flexible than the prefix approach

As far as I know, the QCompleter can only provide a suggested completion list for strings that start by the same string that has been entered for example in a QLineEdit. I'd like it to propose any string that contain this as substring, regardless of…
Christian O'Reilly
  • 1,864
  • 3
  • 18
  • 33
3
votes
0 answers

How to use Qt's QCompleter to do a partial match anywhere?

We want to use QCompleter for searching in a list of items and everything is fine, except just one thing: QCompleter does a search using "partial match at the beginning" instead of "partial match anywhere". IOW: Actual: searching for 'doc' will…
John Thomas
  • 4,075
  • 3
  • 29
  • 41
3
votes
3 answers

how to draw a line between items of a QCompleter as a separator?

I have a QCompleter and a QStringListModel that is set to QCompleter. Now how can I draw a line as separator between items of StringList that is set to QStringListModel. Finally, QCompleter will be set to a QLineEdit.
3
votes
1 answer

PyQt LineEdit with readline completer?

I've been working on a command line tool for which I'm now making a PyQT GUI. I'd like to take my current autocomplete implementation using the readline module, and put that in a QLineEdit text box. Is this possible? Do you have any…
Bradley Powers
  • 717
  • 7
  • 19
1
2 3
8 9