本文整理汇总了C++中QFileDialog::selectFile方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::selectFile方法的具体用法?C++ QFileDialog::selectFile怎么用?C++ QFileDialog::selectFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::selectFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changePOTCAR
void TabEdit::changePOTCAR(QListWidgetItem *item)
{
QSettings settings; // Already set up in avogadro/src/main.cpp
// Get symbol and filename
QStringList strl = item->text().split(":");
QString symbol = strl.at(0).trimmed();
QString filename = strl.at(1).trimmed();
QStringList files;
QString path = settings.value("xtalopt/templates/potcarPath", "").toString();
QFileDialog dialog (NULL, QString("Select pot file for atom %1").arg(symbol), path);
dialog.selectFile(filename);
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec()) {
files = dialog.selectedFiles();
if (files.size() != 1) { return;} // Only one file per element
filename = files.first();
settings.setValue("xtalopt/templates/potcarPath", dialog.directory().absolutePath());
}
else { return;} // User cancel file selection.
// "POTCAR info" is of type
// QList<QHash<QString, QString> >
// e.g. a list of hashes containing
// [atomic symbol : pseudopotential file] pairs
QVariantList potcarInfo = m_opt->optimizer()->getData("POTCAR info").toList();
QVariantHash hash = potcarInfo.at(ui_list_optStep->currentRow()).toHash();
hash.insert(symbol,QVariant(filename));
potcarInfo.replace(ui_list_optStep->currentRow(), hash);
m_opt->optimizer()->setData("POTCAR info", potcarInfo);
qobject_cast<VASPOptimizer*>(m_opt->optimizer())->buildPOTCARs();
updateEditWidget();
}
示例2: tr
void MainWindow::on_actionSave_triggered ()
{
QFile model{modelFilePath};
QString modelFileName {model.fileName()};
QFileDialog savePanel;
savePanel.selectFile(modelFileName);
QString newFileName = QFileDialog::getSaveFileName
(
this,
"Save model",
modelFilePath,
tr("Model3D (*off)")
);
if(newFileName.isEmpty()) //--użytkownik kliknął cancel
return;
else
{
if(model.rename(newFileName))
messageHandling(MessageType::log, "Plik z modelem został zapisany w: "+ newFileName);
else
messageHandling(MessageType::warning, "Plik z modelem nie został zapisany");
}
}
示例3: injectStructureProgress
void TabProgress::injectStructureProgress()
{
// It doesn't matter what xtal was selected
m_context_xtal = NULL;
// Prompt for filename
QSettings settings; // Already set up in avogadro/src/main.cpp
QString filename = settings.value("xtalopt/opt/seedPath",
m_opt->filePath).toString();
// Launch file dialog
QFileDialog dialog (m_dialog,
QString("Select structure file to use as seed"),
filename,
"Common formats (*POSCAR *CONTCAR *.got *.cml *cif"
" *.out);;All Files (*)");
dialog.selectFile(filename);
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec())
filename = dialog.selectedFiles().first();
else { return;} // User cancel file selection.
settings.setValue("xtalopt/opt/seedPath", filename);
// Load in background
QtConcurrent::run(this, &TabProgress::injectStructureProgress_,
filename);
}
示例4: on_saveDebugInfoButton_clicked
/**
* @brief Stores the debug information to a markdown file
*/
void SettingsDialog::on_saveDebugInfoButton_clicked() {
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDirectory(QDir::homePath());
dialog.setNameFilter("Markdown files (*.md)");
dialog.setWindowTitle("Save debug information");
dialog.selectFile("QOwnNotes Debug Information.md");
int ret = dialog.exec();
if (ret == QDialog::Accepted) {
QStringList fileNames = dialog.selectedFiles();
if (fileNames.size() == 0) {
return;
}
QFile file(fileNames.at(0));
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qWarning() << file.errorString();
return;
}
QTextStream out(&file);
out.setCodec("UTF-8");
out << ui->debugInfoTextEdit->toPlainText();
file.flush();
file.close();
}
}
示例5: saveAsDialog
bool FileSystem::saveAsDialog()
{
QFileDialog dialog;
dialog.setMimeTypeFilters(Config::supportedSaveMimeTypes());
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.selectFile(getCurrentAbsoluteFileName());
dialog.setDirectory(getCurrentAbsoluteFileName());
dialog.selectMimeTypeFilter("image/jpeg");
bool success;
if(dialog.exec())
{
QImage img;
if(SaveConfirmation::imageWasChanged(getCurrentAbsoluteFileName()))
{
img = SaveConfirmation::getChagedImage(getCurrentAbsoluteFileName());
success = img.save(dialog.selectedFiles().first());
if(success)
SaveConfirmation::deleteImage(getCurrentAbsoluteFileName());
}
else
{
img.load(getCurrentAbsoluteFileName());
success = img.save(dialog.selectedFiles().first());
}
}
return success;
}
示例6: mousePressEvent
void StoreLabel::mousePressEvent (QMouseEvent *)
{
QFileDialog *fileDialog;
fileDialog = new QFileDialog(this, "Store folder path");
fileDialog->setFileMode(QFileDialog::DirectoryOnly);
fileDialog->selectFile(text());
if (fileDialog->exec())
setText(fileDialog->selectedFiles().at(0));
}
示例7: openBrowseWindow
void LogFilePicker::openBrowseWindow()
{
QFileDialog dialog;
dialog.selectFile(m_fileEditBox->text());
dialog.setFileMode(QFileDialog::AnyFile);
if (!dialog.exec())
return;
m_fileEditBox->setText(dialog.selectedFiles()[0]);
}
示例8: on_scadExecutableBrowse
void Prefs::on_scadExecutableBrowse() {
QFileDialog *dlg = new QFileDialog(this);
dlg->setFilter(QDir::Executable);
dlg->selectFile(getValue("openscad/executable").toString());
QString filename;
if (dlg->exec())
filename = dlg->selectedFiles().first();
else
return;
setValue("openscad/executable", filename);
scadExecutable->setText(filename);
emit scadExecutableChanged(filename);
}
示例9: _getDatabasePathFromFileDialog
QString MainWindow::_getDatabasePathFromFileDialog() const
{
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setOption(QFileDialog::DontConfirmOverwrite);
dialog.selectFile("accountbook.db");
dialog.setWindowTitle("選擇資料庫的位置和名稱");
QString databasePath;
if(dialog.exec())
databasePath = dialog.selectedFiles()[0];
return databasePath;
}
示例10: on_outButton_clicked
void Ruralcooperativequery::on_outButton_clicked()
{
QAbstractItemModel* model=ui.tableView->model();
if (model->rowCount()==0||model==NULL)
{
QString str = str.fromLocal8Bit("提示");
QString str2 = str.fromLocal8Bit("无数据");
QMessageBox box(QMessageBox::Warning,QString::fromLocal8Bit("警告"),str2);
box.setStandardButtons (QMessageBox::Ok);
box.setButtonText (QMessageBox::Ok,QString::fromLocal8Bit("确 定"));
box.exec();
return;
}
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptSave);
dlg.setDirectory(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
dlg.setNameFilter("*.xls");
QList<QTreeWidgetItem*> list= ui.treeWidget->selectedItems();
QTreeWidgetItem*item = list.at(0);
QString strText = item->text(0);
dlg.selectFile(strText+QString::fromLocal8Bit("(农合对应关系)"));
if(dlg.exec()!= QDialog::Accepted)
return;
QString filePath=dlg.selectedFiles()[0];
if(OdbcExcel::saveFromTable(filePath,ui.tableView,"")) {
QString str = str.fromLocal8Bit("提示");
QString str2 = str.fromLocal8Bit("保存成功");
QMessageBox box(QMessageBox::Warning,QString::fromLocal8Bit("警告"),str2);
box.setStandardButtons (QMessageBox::Ok);
box.setButtonText (QMessageBox::Ok,QString::fromLocal8Bit("确 定"));
box.exec();
}
else{
QString str = str.fromLocal8Bit("错误");
QString msg=str.fromLocal8Bit("保存失败!\n\r")+OdbcExcel::getError();
QMessageBox box(QMessageBox::Warning,QString::fromLocal8Bit("警告"),msg);
box.setStandardButtons (QMessageBox::Ok);
box.setButtonText (QMessageBox::Ok,QString::fromLocal8Bit("确 定"));
box.exec();
}
}
示例11: saveToFile
void ReportEditWidget::saveToFile()
{
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptSave);
dlg.setFileMode(QFileDialog::AnyFile);
dlg.setViewMode(QFileDialog::List);
QStringList filters;
filters << tr("All reports (*.xml *.ncr *.ods)");
filters << tr("NcReport (*.ncr)");
filters << tr("CuteReport (*.xml)");
filters << tr("OO Calc (*.ods)");
filters << tr("All files (*.*)");
dlg.setNameFilters(filters);
QString ext;
int type = ui->cmbType->currentKey().toInt();
switch (type) {
case Report::NcReportEngine :
ext = ".ncr";
dlg.selectFilter(filters.at(1));
break;
case Report::CuteReportEngine :
ext = ".xml";
dlg.selectFilter(filters.at(2));
break;
case Report::OpenOfficeEngine :
ext = ".ods";
dlg.selectFilter(filters.at(3));
break;
default:
break;
}
dlg.selectFile(ui->edName->text() + ext);
if (dlg.exec() == QDialog::Accepted) {
QFile f(dlg.selectedFiles().first());
if (!f.open(QIODevice::WriteOnly)) {
QMessageBox::critical(this, tr("Save"), f.errorString());
return;
}
f.write(m_data.toUtf8());
f.close();
}
}
示例12: mousePressEvent
void ExecLabel::mousePressEvent (QMouseEvent *)
{
QFileDialog *fileDialog;
QMessageBox messageBox;
fileDialog = new QFileDialog(this, m_title + " - press Cancel for option to clear field");
if (m_directory)
fileDialog->setFileMode(QFileDialog::DirectoryOnly);
fileDialog->selectFile(text());
if (fileDialog->exec()) {
setText(fileDialog->selectedFiles().at(0));
} else {
messageBox.setText("Do you want to clear this field?");
messageBox.setIcon(QMessageBox::Question);
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
if (messageBox.exec() == QMessageBox::Yes)
setText("");
}
}
示例13: chooseFile
void ReportEditWidget::chooseFile()
{
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.setFileMode(QFileDialog::ExistingFile);
dlg.setViewMode(QFileDialog::List);
QStringList filters;
filters << tr("All reports (*.xml *.ncr *.ods)");
filters << tr("NcReport (*.ncr)");
filters << tr("CuteReport (*.xml)");
filters << tr("OO Calc (*.ods)");
filters << tr("All files (*.*)");
dlg.setNameFilters(filters);
dlg.selectFile(ui->edInFile->text());
if (dlg.exec() == QDialog::Accepted) {
ui->edInFile->setText(QDir::toNativeSeparators(dlg.selectedFiles().first()));
}
}
示例14: saveButtonClicked
void SyntroReview::saveButtonClicked(QAbstractButton *button)
{
QFileDialog *fileDialog;
if (m_CFSState != SYNTROREVIEW_CFS_STATE_OPEN)
return; // no open file anyway
if (button == m_saveFrame){
fileDialog = new QFileDialog(this, "JPEG (.jpg) file name");
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
fileDialog->setFileMode(QFileDialog::AnyFile);
fileDialog->selectFile(m_saveFilePath);
fileDialog->setNameFilter("*.jpg");
fileDialog->setDefaultSuffix("jpg");
if (fileDialog->exec()) {
m_saveFilePath = fileDialog->selectedFiles().at(0);
saveCurrentFrame();
}
}
}
示例15: saveScheme
void AbstractEditTab::saveScheme()
{
SETTINGS("");
QString filename = settings->value(m_opt->getIDString().toLower() +
"/edit/schemePath/", "").toString();
QFileDialog dialog (NULL, tr("Save Optimization Scheme as..."),
filename, "*.scheme;;*.state;;*.*");
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.selectFile(m_opt->optimizer()->getIDString() + ".scheme");
dialog.setFileMode(QFileDialog::AnyFile);
if (dialog.exec())
filename = dialog.selectedFiles().first();
else { // User cancel file selection.
return;
}
settings->setValue(m_opt->getIDString().toLower() +
"/edit/schemePath/", filename);
DESTROY_SETTINGS("");
writeSettings(filename);
}