本文整理汇总了C++中QFileDialog::setAcceptMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::setAcceptMode方法的具体用法?C++ QFileDialog::setAcceptMode怎么用?C++ QFileDialog::setAcceptMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::setAcceptMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runEvent
void runEvent()
{
if( open )
{
widget->setAcceptMode( QFileDialog::AcceptOpen );
widget->setFileMode( QFileDialog::ExistingFile );
}
else
{
widget->setAcceptMode( QFileDialog::AcceptSave );
widget->setFileMode( QFileDialog::AnyFile );
}
}
示例2: save_file_locally
void MainWindow::save_file_locally()
{
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptSave);
dlg.exec();
}
示例3: askForFile
void askForFile() {
QFileDialog * dialog = new QFileDialog(aView());
connect(dialog, SIGNAL(fileSelected(QString)), SLOT(loadFile(QString)));
dialog->setAcceptMode(QFileDialog::AcceptOpen);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
示例4: saveParams
void Advanced::saveParams()
{
QFileDialog dialogRaster;
dialogRaster.setAcceptMode(QFileDialog::AcceptSave);
dialogRaster.setFileMode(QFileDialog::AnyFile);
dialogRaster.setDirectory(QDir::toNativeSeparators(QCoreApplication::applicationDirPath()));
dialogRaster.setFilter(QDir::Files);
dialogRaster.setWindowTitle("Save Projection Parameters");
dialogRaster.setNameFilter("Config files (*.config)");
dialogRaster.exec();
QString filename = dialogRaster.selectedFiles().first();
if (filename.isEmpty())
return;
else
{
QFile file(filename);
if (!file.open(QIODevice::WriteOnly))
{
QMessageBox::information(this, tr("Unable to open file"), file.errorString());
return;
}
QDataStream out (&file);
out.setVersion(12);
//out << ;//Write DATA here
}
}
示例5: open_file_locally
void MainWindow::open_file_locally()
{
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.exec();
}
示例6: onChangeDataDirectory
void MainWindow::onChangeDataDirectory()
{
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.setFileMode(QFileDialog::Directory);
dlg.setOption(QFileDialog::ShowDirsOnly, true);
if (dlg.exec()) {
QString path = dlg.selectedFiles().at(0);
DatabaseDlg dbdlg(QDir(path), this);
if (dbdlg.exec()) {
Parser *p = new Parser(path, m_output);
p->restrictYears(dbdlg.getSelectedYears());
activateWindow();
raise();
p->moveToThread(&m_thread);
connect(&m_thread, SIGNAL(finished()), p, SLOT(deleteLater()));
connect(p, SIGNAL(finished()), this, SLOT(onParseFinished()));
connect(this, SIGNAL(parse()), p, SLOT(parse()));
m_thread.start();
emit parse();
}
}
}
示例7: SaveProjectAs
void ProjectManager::SaveProjectAs()
{
if(m_pBoek == NULL)
{
QMessageBox box(QMessageBox::Information, "Geen project", "Er is geen project geopend!");
box.exec();
return;
}
QFileDialog fileDialog;
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
if(fileDialog.exec())
{
QStringList files = fileDialog.selectedFiles();
if(files.size() >= 1)
{
m_saveLocation = files.first();
save(m_saveLocation);
}
else
{
qWarning("No files selected in QFileDialog but user still managed to click save?");
}
}
}
示例8: on_actionAdd_File_triggered
void MainWindow::on_actionAdd_File_triggered()
{
this->settings->beginGroup(QStringLiteral("paths"));
QFileDialog *dialog = new QFileDialog(this);
DialogMaster::masterDialog(dialog);
dialog->setWindowTitle(tr("Open Icon Archive"));
dialog->setAcceptMode(QFileDialog::AcceptOpen);
dialog->setFileMode(QFileDialog::ExistingFiles);
dialog->setDirectory(this->settings->value(QStringLiteral("openPath")).toString());
QStringList mTypes = byteToStringList(QImageReader::supportedMimeTypes());
mTypes.append(QStringLiteral("application/octet-stream"));
dialog->setMimeTypeFilters(mTypes);
QString selFilter = this->settings->value(QStringLiteral("openFilter")).toString();
qDebug() << selFilter;
if(selFilter.isEmpty()) {
#if defined(Q_OS_WIN)
dialog->selectMimeTypeFilter(QStringLiteral("image/vnd.microsoft.icon"));
#elif defined(Q_OS_OSX)
dialog->selectMimeTypeFilter(QStringLiteral("image/x-icns"));
#else
dialog->selectMimeTypeFilter(QStringLiteral("image/png"));
#endif
} else
dialog->selectNameFilter(selFilter);
this->settings->endGroup();
dialog->open(this, SLOT(fileSelected(QStringList)));
}
示例9: openPlaylist
File FileDialogs::openPlaylist()
{
QStringList filters;
filters << filterByType(File::M3U)
<< filterByType(File::CSV)
<< filterByType(File::JS);
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setFileMode(QFileDialog::ExistingFile);
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;
}
示例10: saveAsLabelledResult
bool ImageViewer::saveAsLabelledResult(QString &pathResult)
{
if(!_srcOcvImage) return false;
if(!_displayImage) return false;
if(!_result_display) return false;
QFileDialog *fDlg = new QFileDialog(this);
fDlg->setWindowTitle(tr("保存标注结果"));
fDlg->setAcceptMode(QFileDialog::AcceptSave);
fDlg->setFileMode(QFileDialog::AnyFile);
fDlg->setViewMode(QFileDialog::Detail);
fDlg->setDirectory(QDir::currentPath());
fDlg->setFilter(MOLI_IMAGE_FILTER);
fDlg->setDefaultSuffix("png");
if(fDlg->exec() == QDialog::Accepted)
{
QString filename = fDlg->selectedFiles()[0];
if(_result_display->save(filename))
{
pathResult = filename;
return true;
}
else return false;
}
else return true;
}
示例11: 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;
}
示例12: on_action_Export_Scenes_triggered
void MainWindow::on_action_Export_Scenes_triggered()
{
QFileDialog fileDialog;
fileDialog.setWindowTitle(tr("Export"));
// Set the dialog for saving files, sets the dialog button to "Save"
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
// Set the dialog to display the Desktop folder as default location
fileDialog.setDirectory(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
// Set the dialog to return the file name wheather the file exists or not
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setNameFilter(tr("XML Data File") + " (*.xml)");
bool wasFileSelected = fileDialog.exec();
QString filePath;
if (wasFileSelected) {
filePath = fileDialog.selectedFiles().at(0);
qDebug() << "Exporting file: " + filePath;
try {
_sceneDataFile->exportTo(filePath);
}
catch (SceneDataFileException& exception)
{
QMessageBox::critical(this,
tr("ERROR: File Export Failed"),
exception.getMessage());
return; // If export failed
}
}
else
{
return; // If no file was selected
}
} // on_action_Export_Scenes_triggered()
示例13: save_as
void MainWindow::save_as()
{
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("xml");
dialog.setNameFilter(tr("xml files (*.xml)"));
if (dialog.exec() == QDialog::Accepted)
{
this->filename = dialog.selectedFiles().at(0);
if (!this->save(this->filename))
{
this->filename = "";
QMessageBox message;
message.setText("Could not save the file.");
message.exec();
}
else // set the new window title
{
this->update_title();
this->change_happened = false; // reset the change watcher
}
}
}
示例14: saveFileAs
void MainWindow::saveFileAs()
{
QFileDialog *saveWindow = new QFileDialog(this);
FILE *saveFile;
QTextStream *fileStream;
QByteArray filenameFopen;
saveWindow->setAcceptMode(QFileDialog::AcceptSave);
saveWindow->setFileMode(QFileDialog::AnyFile);
saveWindow->show();
if(saveWindow->exec())
{
//convert Qstring to char* for the fopen function
filenameFopen = saveWindow->selectedFiles()[0].toLocal8Bit();
saveFile = fopen(filenameFopen.data(), "w");
if(saveFile == NULL)
{
cout << "Erreur" << endl;
}
else
{
fileStream = new QTextStream(saveFile,QIODevice::ReadWrite);
currentDocument->save(*fileStream, 4);
fclose(saveFile);
fileSaved = true;
}
}
}
示例15: open
void AppImportFile::open()
{
const QString MetaIOImageFilter("MetaIO Image (*.mhd)"), DICOMImageFilter("DICOM Images (*.dcm)"), AllFilesFilter("All Files (*)");
QStringList imagesFilter;
imagesFilter << MetaIOImageFilter << DICOMImageFilter << AllFilesFilter;
QFileDialog *openDialog = new QFileDialog(0);
openDialog->setWindowTitle(tr("Select files to open..."));
openDialog->setDirectory(m_workingDirectory);
openDialog->setNameFilters(imagesFilter);
openDialog->selectNameFilter (m_lastExtension);
openDialog->setFileMode(QFileDialog::ExistingFiles);
openDialog->setAcceptMode(QFileDialog::AcceptOpen);
if (openDialog->exec() == QDialog::Accepted)
{
QStringList fileNames = openDialog->selectedFiles();
emit selectedFiles(fileNames);
m_workingDirectory = QFileInfo(fileNames.first()).dir().path();
m_lastExtension = openDialog->selectedNameFilter();
writeSettings();
}
delete openDialog;
}