Qt 6.11 is out! See what's new in the release
blog
[SOLVED] QDir setNameFilter problem, it does not filter
General and Desktop
3
Posts
2
Posters
3.6k
Views
1
Watching
-
I try to list only .cpp file, so I used setNameFilter but anything was changed, it still lists all files.
@QDir dir;
QStringList filters;
filters << "*.cpp" ;
dir.setNameFilters(filters);QString text = QFileDialog::getOpenFileName(this,
tr("Open File"),dir.currentPath());@Where I am wrong?
-
You not needed QDir for filters:
@
QString text = QFileDialog::getOpenFileName(this, tr("Open File"),QDir::currentPath(), "Sources (*.cpp)");
@See: http://doc.qt.nokia.com/4.7/qfiledialog.html#getOpenFileName for more examples