Version 5.10.1 windows mingw32 release question about the Class QFileDialog
-
hi,
i use the QFileDialog's function: selectedMimeTypeFilter(), i want to get the file type .
my code:
QFileDialog dialog(this, tr("Open File"));
QStringList mimeTypeFilters;
const QByteArrayList supportedMimeTypes = QImageReader::supportedMimeTypes();foreach (const QByteArray &mimeTypeName, supportedMimeTypes) mimeTypeFilters.append(mimeTypeName); QString selecttype = userSelectedType.isEmpty() ? QString("image/jpeg") : userSelectedType; dialog.selectMimeTypeFilter(selecttype);
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.exec();
.....QString tempPath = dialog.selectedFiles().first(); userSelectedType = dialog.selectedMimeTypeFilter();
/***************************/
i add the qDebug to print out the value of userSelectedType ,unfortunately, it is always
empty.I want to know the method which i used is right or not .
-
@Hcf134 said in Version 5.10.1 windows mingw32 release question about the Class QFileDialog:
userSelectedType
Where is it defined and set?
-
@jsulm
Thanks your replying!
I define it in the class which i writed above code .class ImageReader : public QWidget
{
/others/
.....
public:
QString getFilePath();
private:
QString userSelectedType;
}QString ImageReader::getFilePath()
{
/*above code */
...
return tempPath;
}