PDA

View Full Version : setViewMode issue of QFileDialog



nikhilqt
18th January 2010, 07:45
QFileDialog l_pFiledDlg;
QString sFilename1;
l_pFiledDlg.setViewMode(QFileDialog::Detail);
sFilename1 = l_pFiledDlg.getOpenFileName(this,tr("Open Files"), sPath, tr("All Files (*.*)"));


Using the above code the filedialog which opens is showing "list" as its view mode. It is not changing to "detail" view by default.

I think everything seems correct, but I do not know why it is not working?

Coises
18th January 2010, 08:39
QFileDialog::getOpenFileName is a static function. As such, it’s not using the l_pFiledDlg instance you created, so the QFileDialog::setViewMode has no effect. I think this:
QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*.*)"));
QString sFilename1;
l_pFiledDlg.setViewMode(QFileDialog::Detail);
if (l_pFiledDlg.exec()) sFilename1 = l_pFiledDlg.selectedFiles()[0];should be close to what you want (though I haven’t tested it, so typos or outright errors would not be surprising).

nikhilqt
18th January 2010, 09:50
Thanks man! It worked. But the file dialog displayed has a different view unlike the static method of getOpenfilename(...). :)