当前位置: 首页>>代码示例>>C++>>正文


C++ QFileDialog::exec方法代码示例

本文整理汇总了C++中QFileDialog::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::exec方法的具体用法?C++ QFileDialog::exec怎么用?C++ QFileDialog::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFileDialog的用法示例。


在下文中一共展示了QFileDialog::exec方法的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();
  }
开发者ID:ajshamp,项目名称:XtalOpt-ajs,代码行数:33,代码来源:tab_edit.cpp

示例2: 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;
        }
    }

}
开发者ID:lomsansnom,项目名称:IHM_OFELI,代码行数:31,代码来源:mainwindow.cpp

示例3: promptForFileName

void CDPWizard::promptForFileName(QLineEdit * theLineEdit, QString theShortName, QString theLongName)
{
    QSettings myQSettings;
    QString myFilterList;
    FileReader::getGdalDriverMap(myFilterList);
    QString myWorkDirString = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",QDir::homeDirPath());

    std::cout << "Filter List: " << myFilterList << std::endl;
    QString myFileNameQString;
    QFileDialog myFileDialog (myWorkDirString,myFilterList,0,"Select " + theLongName ,"Select " + theLongName);
    QString myLastFilter = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter","");
    if (!myLastFilter.isEmpty())
    {
      myFileDialog.setSelectedFilter(myLastFilter);
    }
    if ( myFileDialog.exec() == QDialog::Accepted )
    {
      myFileNameQString = myFileDialog.selectedFile();
      theLineEdit->setText(myFileNameQString);
      QFileInfo myFileInfo(myFileNameQString);
      myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",myFileInfo.dirPath());
      myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter",myFileDialog.selectedFilter());
      checkInputFilenames();
    }
}
开发者ID:alexckp,项目名称:qgis,代码行数:25,代码来源:cdpwizard.cpp

示例4: SelectDeformationField

void QmitkBSplineRegistrationView::SelectDeformationField()
{ 
  // SELECT FOLDER DIALOG
  QFileDialog* w = new QFileDialog( this, "Select Deformation Field" );
  w->setFileMode( QFileDialog::ExistingFiles );
  w->setFilter( "Images (*.mhd)" );
  w->setDirectory("G:\\home\\vanbrugg\\testimages\\deformable"); 

  // RETRIEVE SELECTION
  if ( w->exec() != QDialog::Accepted )
  {
    return;
    cout << "Failed to load" << endl;
  }

  QStringList filenames = w->selectedFiles();
  QStringList::Iterator it = filenames.begin();
  if( it != filenames.end() ) {
    std::string filename = ( *it ).toStdString();
    ++it;     
    QString qStr = QString( filename.c_str() );
    m_Controls.m_DeformationField->setText(qStr); 
  }
   
}
开发者ID:test-fd301,项目名称:MITK,代码行数:25,代码来源:QmitkBSplineRegistrationView.cpp

示例5: exportPalette

void PaletteView::exportPalette(int start, int length) {
	if (start >= 512) {
		return;
	}
	if (start + length > 512) {
		length = 512 - start;
	}
	m_controller->threadInterrupt();
	QFileDialog* dialog = GBAApp::app()->getSaveFileDialog(this, tr("Export palette"), tr("Windows PAL (*.pal);;Adobe Color Table (*.act)"));
	if (!dialog->exec()) {
		m_controller->threadContinue();
		return;
	}
	QString filename = dialog->selectedFiles()[0];
	VFile* vf = VFileDevice::open(filename, O_WRONLY | O_CREAT | O_TRUNC);
	if (!vf) {
		m_controller->threadContinue();
		return;
	}
	QString filter = dialog->selectedNameFilter();
	if (filter.contains("*.pal")) {
		GBAExportPaletteRIFF(vf, length, &m_controller->thread()->gba->video.palette[start]);
	} else if (filter.contains("*.act")) {
		GBAExportPaletteACT(vf, length, &m_controller->thread()->gba->video.palette[start]);
	}
	vf->close(vf);
	m_controller->threadContinue();
}
开发者ID:ikeboy,项目名称:mgba,代码行数:28,代码来源:PaletteView.cpp

示例6: 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);
  }
开发者ID:zfalls,项目名称:XtalOpt-2,代码行数:28,代码来源:tab_progress.cpp

示例7: openDicomdir

void QtDcm::openDicomdir()
{
    this->clearDisplay();
    d->mode = QtDcm::CD;
    // Open a QFileDialog for choosing a Dicomdir
    QFileDialog * dialog = new QFileDialog( this );
    dialog->setFileMode ( QFileDialog::ExistingFile );
    dialog->setDirectory ( QDir::home().dirName() );
    dialog->setWindowTitle ( tr ( "Open dicomdir" ) );
    QStringList filters;
    filters << "Dicomdir files (dicomdir* DICOMDIR*)";
    filters << "Any files (*)";
    dialog->setNameFilters(filters);

    QString fileName;

    if ( dialog->exec() )
    {
        fileName = dialog->selectedFiles() [0];
    }

    dialog->close();

    if ( !fileName.isEmpty() )   // A file has been chosen
    {
        if (QString::compare(fileName, "dicomdir", Qt::CaseInsensitive))
        {
            QtDcmManager::instance()->setDicomdir ( fileName );
            this->loadPatientsFromDicomdir();
        }
    }

    dialog->deleteLater();
}
开发者ID:amirkogithub,项目名称:qtdcm,代码行数:34,代码来源:QtDcm.cpp

示例8: addCal

void preferencedialog::addCal(){
    QFileDialog caldialog;
    caldialog.setFileMode(QFileDialog::ExistingFiles);
    caldialog.setNameFilter("*.cal");
    caldialog.setViewMode(QFileDialog::Detail);
    caldialog.setDirectory("./");

    QStringList stringlist;
    QStringList reducedCalNames;

    for(int i=0; i<calNames.size(); i++){
        QString zahl;
        zahl.setNum(i);
        reducedCalNames.push_back("  "+zahl+":   ..."+calNames.at(i).right(50));
    }

    if (caldialog.exec())
        stringlist = caldialog.selectedFiles();

    for(int i=0; i<stringlist.size(); i++){
        QString zahl;
        zahl.setNum(i);
        calNames.push_back(stringlist.at(i));
        reducedCalNames.push_back("  "+zahl+":   ..."+stringlist.at(i).right(50));
    }

    bla->setStringList(reducedCalNames);
    ui->listView->setModel(bla);



}
开发者ID:phScholz,项目名称:xiaStarter,代码行数:32,代码来源:preferencedialog.cpp

示例9: on_actionOpen_triggered

void MainWindow::on_actionOpen_triggered()
{
    on_actionReal_Time_toggled(false);
    QFileDialog * dialog = new QFileDialog(this);
    dialog->setNameFilter(tr("data files (*.txt)"));
    dialog->setDirectory(QDir::currentPath());
    dialog->exec();
    QStringList filename_list = dialog->selectedFiles();
    QString datafilename = filename_list.first();

    QFile datafile(datafilename);
    if (!datafile.open(QIODevice::ReadOnly))
        return;

    QTextStream in_stream(&datafile);

    QVector<QPoint> in_points;

    while (!in_stream.atEnd())
    {
        float x, y;
        in_stream >> x >> y;
        in_points << QPoint(x, y);
        //qDebug() << x << ", " << y;
    }

    if (in_points.last().x() == 0 && in_points.last().y() == 0)
    {
        in_points.pop_back();
    }

    points = in_points;
    update();
    //on_actionPerform_triggered();
}
开发者ID:Lucinda-Aemilia,项目名称:delaunay-1,代码行数:35,代码来源:mainwindow.cpp

示例10: openImage

void ossimQtSingleImageWindow::openImage()
{
    QString caption = "iview : open image";
    QString directory;
    if (!theLastOpenedDirectory.empty())
    {
        if (theLastOpenedDirectory.exists())
        {
            directory = theLastOpenedDirectory.c_str();
        }
    }

    QFileDialog* fd = new QFileDialog( this, caption, directory );
    fd->setFileMode( QFileDialog::ExistingFile );

    ossimFilename fileName;

    if ( fd->exec() == QDialog::Accepted )
    {
        fileName = fd->selectedFile().ascii();
        theLastOpenedDirectory = fileName.path();
    }

    delete fd;
    fd = 0;

    if (fileName.empty())
    {
        return;
    }

    displayImage(fileName);
}
开发者ID:renyu310,项目名称:ossim-svn,代码行数:33,代码来源:ossimQtSingleImageWindow.cpp

示例11: file

void
WaveMaker::loadFile()
{
  QFileDialog* fd = new QFileDialog(this, "Wave Maker Input File", TRUE);
  fd->setMode(QFileDialog::AnyFile);
  fd->setViewMode(QFileDialog::Detail);
  QString fileName;
  if (fd->exec() == QDialog::Accepted)
    {
      fileName = fd->selectedFile();
      printf("Loading new file: %s\n", fileName.latin1());
      setComment("File Name", fileName);
      wave.clear();
      QFile file(fileName);
      if (file.open(IO_ReadOnly))
        {
          QTextStream stream(&file);
          double value;
          while (!stream.atEnd())
            {
              stream >> value;
              wave.push_back(value);
            }
          filename = fileName;
        }
开发者ID:fparaggio,项目名称:PuggleLinux,代码行数:25,代码来源:wave_maker.cpp

示例12: open_file_locally

void MainWindow::open_file_locally()
{
  QFileDialog dlg;

  dlg.setAcceptMode(QFileDialog::AcceptOpen);
  dlg.exec();
}
开发者ID:BijanZarif,项目名称:coolfluid3,代码行数:7,代码来源:MainWindow.cpp

示例13: save_file_locally

void MainWindow::save_file_locally()
{
  QFileDialog dlg;

  dlg.setAcceptMode(QFileDialog::AcceptSave);
  dlg.exec();
}
开发者ID:BijanZarif,项目名称:coolfluid3,代码行数:7,代码来源:MainWindow.cpp

示例14: buttonPressed

void FileNameEditorWidget::buttonPressed() {
  QFileDialog *dlg = new QFileDialog(this, "Choose a file", basePath, fileFilter);
  dlg->setModal(true);
  dlg->setFileMode(QFileDialog::ExistingFile);

  if (dlg->exec() == QDialog::Accepted) {
    QString file = dlg->selectedFiles().first();

    if (!file.isNull()) {
      QStringList currentDir = QDir::currentPath().split(QDir::separator());
      QStringList filePath = QFileInfo(file).dir().absolutePath().split(QDir::separator());
      QString relativePath = "";

      while ((!currentDir.empty() && !filePath.empty()) && (currentDir.front()
             == filePath.front())) {
        currentDir.pop_front();
        filePath.pop_front();
      }

      while (!currentDir.empty()) {
        relativePath += "..";
        relativePath += QDir::separator();
        currentDir.pop_front();
      }

      if (!filePath.empty())
        relativePath += filePath.join((const QString) (QChar) QDir::separator())
                        + QDir::separator();

      setFileName(relativePath + QFileInfo(file).fileName());
    }
  }

  delete dlg;
}
开发者ID:kdbanman,项目名称:browseRDF,代码行数:35,代码来源:FileNameEditorWidget.cpp

示例15: 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();
    }
}
开发者ID:calis2002,项目名称:QOwnNotes,代码行数:33,代码来源:settingsdialog.cpp


注:本文中的QFileDialog::exec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。