本文整理汇总了C++中QFileDialog::history方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::history方法的具体用法?C++ QFileDialog::history怎么用?C++ QFileDialog::history使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::history方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_tbSaveImage_clicked
void WatchVector::on_tbSaveImage_clicked()
{
static QStringList history;
static QDir directory = QDir::current();
if (m_pImageView) {
QFileDialog *sDialog = new QFileDialog(this, QString("Save image"));
sDialog->setAcceptMode(QFileDialog::AcceptSave);
sDialog->setFileMode(QFileDialog::AnyFile);
QStringList formatDesc;
formatDesc << "Portable Network Graphics (*.png)"
<< "Windows Bitmap (*.bmp)"
<< "Joint Photographic Experts Group (*.jpg, *.jepg)"
<< "Portable Pixmap (*.ppm)"
<< "Tagged Image File Format (*.tif, *.tiff)"
<< "X11 Bitmap (*.xbm, *.xpm)";
sDialog->setFilters(formatDesc);
if (!(history.isEmpty())) {
sDialog->setHistory(history);
}
sDialog->setDirectory(directory);
if (sDialog->exec()) {
QStringList files = sDialog->selectedFiles();
if (!files.isEmpty()) {
QString selected = files[0];
QFileInfo fileInfo(selected);
QImage *img;
img = drawNewImage(false);
if (!(img->save(selected))) {
QString forceFilter;
QString filter = sDialog->selectedFilter();
if (filter == QString("Portable Network Graphics (*.png)")) {
forceFilter.append("png");
} else if (filter == QString("Windows Bitmap (*.bmp)")) {
forceFilter.append("bmp");
} else if (filter == QString("Joint Photographic Experts Group (*.jpg, *.jepg)")) {
forceFilter.append("jpg");
} else if (filter == QString("Portable Pixmap (*.ppm)")) {
forceFilter.append("ppm");
} else if (filter == QString("Tagged Image File Format (*.tif, *.tiff)")) {
forceFilter.append("tif");
} else if (filter == QString("X11 Bitmap (*.xbm, *.xpm)")) {
forceFilter.append("xbm");
}
img->save(selected, forceFilter.toLatin1().data());
}
delete img;
}
}
history = sDialog->history();
directory = sDialog->directory();
delete sDialog;
}
}