QString * selectedFilter
= 0, Options options
= 0){ QString res
= QFileDialog::getSaveFileName(parent, caption, dir, filter, selectedFilter, options
);
#ifndef Q_OS_WIN
if(selectedFilter){
QRegExp filterRx
(".*\\(\\*\\.(.*)\\)");
if(filterRx.exactMatch(*selectedFilter))
res.append("."+filterRx.cap(1));
}
#endif
return res;
}
QString getSaveFileNameWithExtension(QWidget * parent = 0, const QString & caption = QString(),
const QString & dir = QString(), const QString & filter = QString(),
QString * selectedFilter = 0, Options options = 0){
QString res = QFileDialog::getSaveFileName(parent, caption, dir, filter, selectedFilter, options);
#ifndef Q_OS_WIN
if(selectedFilter){
QRegExp filterRx(".*\\(\\*\\.(.*)\\)");
if(filterRx.exactMatch(*selectedFilter))
res.append("."+filterRx.cap(1));
}
#endif
return res;
}
To copy to clipboard, switch view to plain text mode
Note this of course won't work if you select a filter such as "Images (*.png *.xpm *.jpg)" but I understand it wouldn't work on Windows either.
Bookmarks