September 19, 2011

endhck endhck
Lab Rat
10 posts

[SOLVED] QDir setNameFilter problem, it does not filter

 

I try to list only .cpp file, so I used setNameFilter but anything was changed, it still lists all files.

  1. QDir dir;
  2.      QStringList filters;
  3.      filters << "*.cpp" ;
  4.      dir.setNameFilters(filters);
  5.  
  6.  QString text = QFileDialog::getOpenFileName(this,
  7.   tr("Open File"),dir.currentPath());

Where I am wrong?

2 replies

September 19, 2011

Vass Vass
Ant Farmer
740 posts

You not needed QDir for filters:

  1.  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

 Signature 


Vasiliy

September 19, 2011

endhck endhck
Lab Rat
10 posts

It is worked, thanks

 
  ‹‹ QComboBox > QListView      Including (and viewing) PDF file in Qt Help Collection ››

You must log in to post a reply. Not a member yet? Register here!