Discussion:
[Qt-creator] QCompleter with Regular Expresion
Freddy Martinez Garcia
2015-07-31 16:20:54 UTC
Permalink
Hi guys... can I use regular expressions with QCompleter ???

I need to do that when I'm typing in a QLineEdit

regards



*============================================="El tamaño de tus logros
depende del tamaño de tus metas." *

*C++ and Qt Senior Developer*

*Lic. Computer Science*

*Buenos Aires, Argentina*
Tomaz Canabrava
2015-07-31 16:29:41 UTC
Permalink
On Fri, Jul 31, 2015 at 1:20 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
Hi guys... can I use regular expressions with QCompleter ???
You cant easily do that ( unless you override the model that QCompleter has
), but you can use a QSortFilterProxyModel and a QComboBox with the same
effect.
Freddy Martinez Garcia
2015-07-31 18:09:32 UTC
Permalink
I can't use combobox because the lineedit is used for searching...

about the QSirtFilterProxyModel, the problems is that QComplet build his
own model inside when you give him a model... is what i'm seeing in its
behavior...

for that is my question

regards




*============================================="El tamaño de tus logros
depende del tamaño de tus metas." *

*C++ and Qt Senior Developer*

*Lic. Computer Science*

*Buenos Aires, Argentina*
Post by Tomaz Canabrava
On Fri, Jul 31, 2015 at 1:20 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
Hi guys... can I use regular expressions with QCompleter ???
You cant easily do that ( unless you override the model that QCompleter
has ), but you can use a QSortFilterProxyModel and a QComboBox with the
same effect.
Tomaz Canabrava
2015-07-31 18:19:55 UTC
Permalink
On Fri, Jul 31, 2015 at 3:09 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
I can't use combobox because the lineedit is used for searching...
You can use a QLineEdit and a QListView to get the same effect as the
QCompleter,
you need to hook up a few things, of course:
QLineEdit::textChanged signal should be connected to the
QSortFilterProxyModel::invalidate

QSortFilterProxyModel should be the model on the QListView
the show/hide events of the QListView should be deal with and you will need
a eventFilter to handle the up/down keys to send them to the QListView from
within the QLineEdit

It's doable ( I have something like this in my particular software if you
wanna take a look ) - I had to create this because QCompleter doesn't deal
with QRegExp.

(also, if it's desirable, we could add a new CompletionMode on QCompleter -
QCompleter::RegExpCompletion )
Post by Freddy Martinez Garcia
about the QSirtFilterProxyModel, the problems is that QComplet build his
own model inside when you give him a model... is what i'm seeing in its
behavior...
for that is my question
regards
*============================================="El tamaño de tus logros
depende del tamaño de tus metas." *
*C++ and Qt Senior Developer*
*Lic. Computer Science*
*Buenos Aires, Argentina*
Post by Tomaz Canabrava
On Fri, Jul 31, 2015 at 1:20 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
Hi guys... can I use regular expressions with QCompleter ???
You cant easily do that ( unless you override the model that QCompleter
has ), but you can use a QSortFilterProxyModel and a QComboBox with the
same effect.
Freddy Martinez Garcia
2015-07-31 19:04:49 UTC
Permalink
That's will be great, add a QCompleter::RegExpCompletion... if you let me
take a look to your code that's will be great...

regards bro




*============================================="El tamaño de tus logros
depende del tamaño de tus metas." *

*C++ and Qt Senior Developer*

*Lic. Computer Science*

*Buenos Aires, Argentina*
Post by Tomaz Canabrava
On Fri, Jul 31, 2015 at 3:09 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
I can't use combobox because the lineedit is used for searching...
You can use a QLineEdit and a QListView to get the same effect as the
QCompleter,
QLineEdit::textChanged signal should be connected to the
QSortFilterProxyModel::invalidate
QSortFilterProxyModel should be the model on the QListView
the show/hide events of the QListView should be deal with and you will
need a eventFilter to handle the up/down keys to send them to the QListView
from within the QLineEdit
It's doable ( I have something like this in my particular software if you
wanna take a look ) - I had to create this because QCompleter doesn't deal
with QRegExp.
(also, if it's desirable, we could add a new CompletionMode on QCompleter
- QCompleter::RegExpCompletion )
Post by Freddy Martinez Garcia
about the QSirtFilterProxyModel, the problems is that QComplet build his
own model inside when you give him a model... is what i'm seeing in its
behavior...
for that is my question
regards
*============================================="El tamaño de tus logros
depende del tamaño de tus metas." *
*C++ and Qt Senior Developer*
*Lic. Computer Science*
*Buenos Aires, Argentina*
Post by Tomaz Canabrava
On Fri, Jul 31, 2015 at 1:20 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
Hi guys... can I use regular expressions with QCompleter ???
You cant easily do that ( unless you override the model that QCompleter
has ), but you can use a QSortFilterProxyModel and a QComboBox with the
same effect.
Diego Iastrubni
2015-08-02 10:05:20 UTC
Permalink
Post by Tomaz Canabrava
On Fri, Jul 31, 2015 at 3:09 PM, Freddy Martinez Garcia <
Post by Freddy Martinez Garcia
I can't use combobox because the lineedit is used for searching...
It's doable ( I have something like this in my particular software if you
wanna take a look ) - I had to create this because QCompleter doesn't deal
with QRegExp.
(also, if it's desirable, we could add a new CompletionMode on QCompleter
- QCompleter::RegExpCompletion )
Actually - this is not enough. I need more flexibility for my project.
RegEx is very limiting. I want fuzzy search, and my own fuzzy search.

Direction - can you implement sublime's searcg (control+p) using QCompleter?
Loading...