Efe Şafak
Efe Şafak

Reputation: 35

How to enter input separated by semi colon by using setInputMask()

My goal is to display only files which user wants to see. For instance, "*.h; *.txt" as an input should shows the only *.h and *.txt files in selected folder. The program works for only one input(ie. *.h) The code:

QString mask = ";";
 QStringList stringList(ui->lineEdit->text());
ui->lineEdit->setInputMask(mask);

QFileInfoList fileList = qdir.entryInfoList(QStringList() << stringList, QDir::Files, QDir::Size);

The program display when the users enter input only one type of file: enter image description here

But it does not display when the users enter input as *.h; *.cpp enter image description here

Best regards!

Upvotes: 0

Views: 42

Answers (1)

Efe Şafak
Efe Şafak

Reputation: 35

I solved it. All I need to do was

QString str = ui->lineEdit->text();
QStringList stringList = str.split(QLatin1Char(';'));
QFileInfoList fileList = qdir.entryInfoList(QStringList() << stringList, QDir::Files, QDir::Size);

Upvotes: 0

Related Questions