PDA

View Full Version : QRegularExpression



fitoutT
14th May 2020, 12:37
Hi,

I am having a small problem that I cannot get my head around.

I have a tableview with multiple columns and a lineedits to filter each column, using QRegularExpressions for the pattern to use.
It works to a fashion as much it picks the first capital letter or number of the column string as it should, but also picks up on secondary and third words with capitals and numbers in the same string, which it should not.
I have tested my pattern with the online regex tester and using the same strings and it works as it should.
so I take from that my code must be in error.
could someone please look at my code and point me in the right direction.
thank you in advance




QRegularExpression re("^[A-Za-z0-9]{1,1}"); // [A-Za-z0-9] \\w

QSortFilterProxyModel *systemFilter = new QSortFilterProxyModel(model);
systemFilter->setSourceModel(model);
systemFilter->setFilterKeyColumn(1);
systemFilter->setFilterRegularExpression(re);

connect(ui->lineEditSystem, SIGNAL(textEdited(QString)), systemFilter, SLOT(setFilterRegularExpression(QString)));