tags:

views:

39

answers:

0

I have a QfileDialog that it is opened when I push in a button. This button actives a signal and call a Slot with this code:

QString s =  QFileDialog::getOpenFileName ( 

                this,  
                "Open a Map" ,  
                lastPath,  
                "Maps (*.png *.bmp);;Info (*.xml)" 
                );

I don't understand why, but the first time I push the button, the Qfiledialog filters rightly. But the following times don't work fine. It filters nothing.

Ok, I have tried another way:

   QFileDialog dialog(this);
   dialog.setFileMode(QFileDialog::AnyFile);
   dialog.setNameFilter(tr("Images (*.png)"));
   dialog.setViewMode(QFileDialog::Detail);

  QStringList fileNames;
  if (dialog.exec())
  fileNames = dialog.selectedFiles();

If I use this method, the window is not a ubuntu window, it is a Qdialog window, I suppose. But works fine anytime.