Problem with QFileDialog and QFileDialog::DontUseNativeDialog
-
Error with the preview of image files, they are not shown. If I use it natively, the preview is shown. Any solution?
Here is my codeQFileDialog dialog(padre, "Load Icon", nombreFile, "Image files (*.png *.jpg *.bmp *.gif)"); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setViewMode(QFileDialog::List); dialog.setOptions(QFileDialog::DontUseNativeDialog); dialog.setGeometry(padre->geometry()); QString nombreFile1; if (dialog.exec()==QDialog::Accepted) nombreFile1 = dialog.selectedFiles().first(); rect=dialog.geometry(); if (nombreFile1.isEmpty()) nombreFile=dialog.directory().absolutePath(); else { nombreFile=nombreFile1; QPixmap pixmap(nombreFile); if (pixmap.isNull()) error(MainWindow::tr("File fault")); else { pixmap=pixmap.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); pixmap.save(sss); rt=true; } }
And this is how it looks with DontUseNativeDialog
And now with native
-
@JonexElectronic said in Problem with QFileDialog and QFileDialog::DontUseNativeDialog:
Error with the preview of image files, they are not shown. If I use it natively, the preview is shown. Any solution?
dialog.setViewMode(QFileDialog::List);
What do you expect when you set QFileDialog::List? The Qt filedialog does not support previews.
-
@Christian-Ehrlicher So, what should I use? Is there something I can use then that allows me to preview?
-
@JonexElectronic
If (a) the non-native (i.e. Qt) dialog does not offer preview and (b) the native one either also does not or for some reason you cannot use it, then you would have no choice but to write your own which did offer this "preview" facility.