本文整理汇总了C++中QFileDialog::setConfirmOverwrite方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::setConfirmOverwrite方法的具体用法?C++ QFileDialog::setConfirmOverwrite怎么用?C++ QFileDialog::setConfirmOverwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::setConfirmOverwrite方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeImageFileDialog
void DialogGui::initializeImageFileDialog(QFileDialog &fileDialog, QFileDialog::Options options, QFileDialog::FileMode fm)
{
fileDialog.setConfirmOverwrite( !(options & QFileDialog::DontConfirmOverwrite) );
fileDialog.setResolveSymlinks( !(options & QFileDialog::DontResolveSymlinks) );
fileDialog.setIconProvider(ensureIconProvider());
fileDialog.setFileMode(fm);
}
示例2: savePlaylist
File FileDialogs::savePlaylist()
{
QStringList filters;
filters << filterByType(File::M3U)
<< filterByType(File::M3UClean)
<< filterByType(File::M3UUdpxy)
<< filterByType(File::CSV)
<< filterByType(File::JS);
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setConfirmOverwrite(true);
dialog.setNameFilters(filters);
QString fileName;
File::Type type = File::Unknown;
if (dialog.exec()) {
fileName = dialog.selectedFiles()[0];
for (int i = 0; i < 50; i++) {
if (dialog.selectedNameFilter() == filterByType(File::Type(i))) {
type = File::Type(i);
}
}
}
File file;
file.path = fileName;
file.type = type;
return file;
}
示例3: onExport
void dtkPlotViewToolBar::onExport(void)
{
const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
QStringList filters;
filters += "PDF Documents (*.pdf)";
#ifndef QWT_NO_SVG
filters += "SVG Documents (*.svg)";
#endif
filters += "Postscript Documents (*.ps)";
for(int i = 0; i < imageFormats.size(); i++) {
QString imageFilter;
imageFilter += imageFormats[i].toUpper();
imageFilter += " (*.";
imageFilter += imageFormats[i];
imageFilter += ")";
filters += imageFilter;
}
QFileDialog *dialog = new QFileDialog(0, "Export plot", QDir::homePath(), filters.join(";;"));
dialog->setStyleSheet("background-color: none ; color: none; background: none;");
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setConfirmOverwrite(true);
dialog->setFileMode(QFileDialog::AnyFile);
QRegExp filter_regex(QLatin1String("(?:^\\*\\.(?!.*\\()|\\(\\*\\.)(\\w+)"));
if (dialog->exec() == QDialog::Accepted) {
QString fileName = dialog->selectedFiles().first();
QFileInfo info(fileName);
if (info.suffix().isEmpty() && !dialog->selectedNameFilter().isEmpty()) {
if (filter_regex.indexIn(dialog->selectedNameFilter()) != -1) {
QString extension = filter_regex.cap(1);
fileName += QLatin1String(".") + extension;
}
}
this->onExport(fileName);
}
}
示例4: saveImage
void GLWidget::saveImage() {
rgbImage temp;
if ( rb!=0 ) {
rb->lockRead();
int idx=rb->curRead();
FrameData * frame = rb->getPointer ( idx );
VisualizationFrame * vis_frame=(VisualizationFrame *)(frame->map.get("vis_frame"));
if (vis_frame !=0 && vis_frame->valid) {
temp.copy ( vis_frame->data );
rb->unlockRead();
} else {
rb->unlockRead();
return;
}
}
if ( temp.getWidth() > 1 && temp.getHeight() > 1 ) {
QFileDialog dialog ( this,
"Export image to file...",
"",
"PNG (*.png)" );
dialog.setConfirmOverwrite ( true );
dialog.setDefaultSuffix ( "png" );
dialog.setAcceptMode ( QFileDialog::AcceptSave );
if ( dialog.exec() ) {
if ( dialog.selectedFiles().size() > 0 ) {
QString filename=dialog.selectedFiles().at ( 0 );
if ( temp.save ( filename.toStdString() ) ) {
QMessageBox::information ( this, "Success","PNG was saved successfully." );
} else {
QMessageBox::warning ( this, "Error","Unknown error while saving PNG." );
}
}
}
}
}
示例5: downloadRequested
void NWebView::downloadRequested(QNetworkRequest req) {
QString urlString = req.url().toString();
if (urlString == "") {
downloadImageAction()->trigger();
return;
}
if (urlString.startsWith("nnres:")) {
int pos = urlString.indexOf(global.attachmentNameDelimeter);
QString extension = "";
if (pos > 0) {
extension = urlString.mid(pos+global.attachmentNameDelimeter.length());
urlString = urlString.mid(0,pos);
}
urlString = urlString.mid(6);
qint32 lid = urlString.toInt();
ResourceTable resTable(global.db);
Resource r;
resTable.get(r, lid, false);
QString filename;
ResourceAttributes attributes;
if (r.attributes.isSet())
attributes = r.attributes;
if (attributes.fileName.isSet())
filename = attributes.fileName;
else
filename = urlString + QString(".") + extension;
QFileDialog fd;
fd.setFileMode(QFileDialog::AnyFile);
fd.setWindowTitle(tr("Save File"));
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.selectFile(filename);
fd.setConfirmOverwrite(true);
if (fd.exec()) {
if (fd.selectedFiles().size() == 0)
return;
filename = fd.selectedFiles()[0];
QFile newFile(filename);
newFile.open(QIODevice::WriteOnly);
Data d;
if (r.data.isSet())
d = r.data;
QByteArray body;
if (d.body.isSet())
body = d.body;
int size = 0;
if (d.size.isSet())
size = d.size;
newFile.write(body, size);
newFile.close();
return;
}
}
if (urlString.startsWith("file:////")) {
if (!req.url().isValid())
return;
urlString = urlString.mid(8);
QFileDialog fd;
fd.setFileMode(QFileDialog::AnyFile);
fd.setWindowTitle(tr("Save File"));
fd.setAcceptMode(QFileDialog::AcceptSave);
QString oldname = urlString;
fd.selectFile(urlString.replace(global.fileManager.getDbaDirPath(), ""));
fd.setConfirmOverwrite(true);
if (fd.exec()) {
if (fd.selectedFiles().size() == 0)
return;
QString newname = fd.selectedFiles()[0];
QFile::remove(urlString);
QFile::copy(oldname, newname);
return;
}
}
}
示例6: getSaveFileName
//.........这里部分代码省略.........
if (aSelectedFilter)
*aSelectedFilter = QString::null;
/* Local event loop to run while waiting for the result from another
* thread */
QEventLoop loop;
QString startWith = QDir::toNativeSeparators (aStartWith);
LoopObject loopObject ((QEvent::Type) GetOpenFileNameEvent::TypeId, loop);
if (aParent)
aParent->setWindowModality (Qt::WindowModal);
Thread openDirThread (aParent, &loopObject, startWith, aFilters, aCaption, fConfirmOverwrite);
openDirThread.start();
loop.exec();
openDirThread.wait();
if (aParent)
aParent->setWindowModality (Qt::NonModal);
return loopObject.result();
#elif defined (VBOX_WS_X11) && (QT_VERSION < 0x040400)
/* Here is workaround for Qt4.3 bug with QFileDialog which crushes when
* gets initial path as hidden directory if no hidden files are shown.
* See http://trolltech.com/developer/task-tracker/index_html?method=entry&id=193483
* for details */
QFileDialog dlg (aParent);
dlg.setWindowTitle (aCaption);
dlg.setDirectory (aStartWith);
dlg.setFilter (aFilters);
dlg.setFileMode (QFileDialog::QFileDialog::AnyFile);
dlg.setAcceptMode (QFileDialog::AcceptSave);
if (aSelectedFilter)
dlg.selectFilter (*aSelectedFilter);
dlg.setResolveSymlinks (aResolveSymlinks);
dlg.setConfirmOverwrite (fConfirmOverwrite);
QAction *hidden = dlg.findChild <QAction*> ("qt_show_hidden_action");
if (hidden)
{
hidden->trigger();
hidden->setVisible (false);
}
return dlg.exec() == QDialog::Accepted ? dlg.selectedFiles().value (0, "") : QString::null;
#elif defined (VBOX_WS_MAC) && (QT_VERSION >= 0x040600) && (QT_VERSION < 0x050000)
/* After 4.5 exec ignores the Qt::Sheet flag.
* See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why.
* We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x
* which result in showing the native & the Qt dialog at the same time. */
QFileDialog dlg(aParent);
dlg.setWindowTitle(aCaption);
/* Some predictive algorithm which seems missed in native code. */
QDir dir(aStartWith);
while (!dir.isRoot() && !dir.exists())
dir = QDir(QFileInfo(dir.absolutePath()).absolutePath());
const QString strDirectory = dir.absolutePath();
if (!strDirectory.isNull())
dlg.setDirectory(strDirectory);
if (strDirectory != aStartWith)
dlg.selectFile(QFileInfo(aStartWith).absoluteFilePath());
dlg.setNameFilter(aFilters);
dlg.setFileMode(QFileDialog::AnyFile);
dlg.setAcceptMode(QFileDialog::AcceptSave);
if (aSelectedFilter)
dlg.selectFilter(*aSelectedFilter);
dlg.setResolveSymlinks(aResolveSymlinks);
dlg.setConfirmOverwrite(fConfirmOverwrite);
QEventLoop eventLoop;
QObject::connect(&dlg, SIGNAL(finished(int)),
&eventLoop, SLOT(quit()));
dlg.open();
eventLoop.exec();
return dlg.result() == QDialog::Accepted ? dlg.selectedFiles().value(0, QString()) : QString();
#else
QFileDialog::Options o;
# if defined (VBOX_WS_X11)
/** @todo see http://bugs.kde.org/show_bug.cgi?id=210904, make it conditional
* when this bug is fixed (xtracker 5167)
* Apparently not necessary anymore (xtracker 5748)! */
// if (vboxGlobal().isKWinManaged())
// o |= QFileDialog::DontUseNativeDialog;
# endif
if (!aResolveSymlinks)
o |= QFileDialog::DontResolveSymlinks;
if (!fConfirmOverwrite)
o |= QFileDialog::DontConfirmOverwrite;
return QFileDialog::getSaveFileName (aParent, aCaption, aStartWith,
aFilters, aSelectedFilter, o);
#endif
}