本文整理汇总了C++中QFileDialog::directory方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::directory方法的具体用法?C++ QFileDialog::directory怎么用?C++ QFileDialog::directory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::directory方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: downloadDirSelected
void MusicSettingWidget::downloadDirSelected(int index)
{
QFileDialog dialog;
dialog.setFileMode(QFileDialog::Directory );
dialog.setViewMode(QFileDialog::Detail);
if(dialog.exec())
{
QString path;
if(!(path = dialog.directory().absolutePath()).isEmpty())
{
index == 0 ? ui->downloadDirEdit->setText(path)
: ui->downloadLrcDirEdit->setText(path);
}
}
}
示例2: GetFilename
bool RegEdit::GetFilename(QString& filename, bool save)
{
QFileDialog *fd = new QFileDialog(this);
if(save)
fd->setAcceptMode(QFileDialog::AcceptSave);
fd->setFilter("Description files (*.xml);;All files (*)");
fd->setDirectory(Settings::Get()->value("loaddescdir", QDir::currentPath()).toString());
if(fd->exec())
{
QStringList filenames = fd->selectedFiles();
filename = filenames[0];
Settings::Get()->setValue("loaddescdir", fd->directory().absolutePath());
return true;
}
else
return false;
}
示例3: QFileDialog
void
pfmPage::slotPFMFileBrowse ()
{
QStringList files, filters;
QString file;
QFileDialog *fd = new QFileDialog (this, tr ("pfmLoadM Open PFM Structure"));
fd->setViewMode (QFileDialog::List);
// Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
// This function is in the nvutility library.
setSidebarUrls (fd, pfm_global->output_dir);
filters << tr ("PFM (*.pfm)");
fd->setFilters (filters);
fd->setFileMode (QFileDialog::AnyFile);
fd->selectFilter (tr ("PFM (*.pfm)"));
if (fd->exec () == QDialog::Accepted)
{
// Save the directory that we were in when we selected a file.
pfm_global->output_dir = fd->directory ().absolutePath ();
files = fd->selectedFiles ();
pfm_def->name = files.at (0);
if (!pfm_def->name.isEmpty())
{
if (!pfm_def->name.endsWith (".pfm")) pfm_def->name.append (".pfm");
// This will trigger slotPFMFileEdit.
pfm_file_edit->setText (pfm_def->name);
}
}
}
示例4: OnLoadDesc
void MainWindow::OnLoadDesc()
{
QFileDialog *fd = new QFileDialog(this);
fd->setFilter("XML files (*.xml);;All files (*)");
fd->setFileMode(QFileDialog::ExistingFiles);
fd->setDirectory(Settings::Get()->value("loaddescdir", QDir::currentPath()).toString());
if(fd->exec())
{
QStringList filenames = fd->selectedFiles();
for(int i = 0; i < filenames.size(); i++)
if(!m_backend->LoadSocDesc(filenames[i]))
{
QMessageBox msg;
msg.setText(QString("Cannot load ") + filenames[i]);
msg.exec();
}
Settings::Get()->setValue("loaddescdir", fd->directory().absolutePath());
}
}
示例5: background_file_open
void MainWindow::background_file_open()
{
QFileDialog dialog;
//dialog.setDirectory( starting_dir );
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec()) {
QStringList filenames = dialog.selectedFiles();
background_file_name = filenames.at(0);
set_background = true;
starting_dir = dialog.directory();
ui->actionClosed_Aperature->setDisabled(false);
emit primaset(background_file_name);
}
else
{
set_background = false;
}
}
示例6: on_ptnsavedir_clicked
void Widget::on_ptnsavedir_clicked()
{
QFileDialog* openFilePath = new QFileDialog( this, " 请选择保存目录", "file"); //打开一个目录选择对话框
openFilePath->setFileMode( QFileDialog::DirectoryOnly );
if ( openFilePath->exec() == QDialog::Accepted )
{
//qDebug()<<openFilePath->directory().absolutePath();
QString m_savePath=openFilePath->directory().absolutePath();
//QString path=QDir::currentPath();//获取程序当前目录
m_savePath.replace("/","\\");//将地址中的"/"替换为"\",因为在Windows下使用的是"\"。
//QProcess::startDetached("explorer "+path);//打开上面获取的目录
/*
bool flag=false;
QString temp2;
for(int i=0;i!=m_savePath.size();++i)
{
if(m_savePath.at(i)==QChar('/'))
{
if(!flag)
{
temp2.append('\\');
}
flag=true;
}
else
{
temp2.append(m_savePath.at(i));
flag=false;
}
}
*/
ui->ldtdir->setText(m_savePath);
}
setSavePath();
delete openFilePath;
}
示例7: fd
void
pfmPage::slotAreaFileBrowse ()
{
QFileDialog fd (this, tr ("pfmLoadM Area File"));
fd.setViewMode (QFileDialog::List);
// Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
// This function is in the nvutility library.
setSidebarUrls (&fd, pfm_global->area_dir);
QStringList filters;
filters << tr ("Area file (*.ARE *.are *.afs)");
fd.setFilters (filters);
fd.setFileMode (QFileDialog::ExistingFile);
fd.selectFilter (tr ("Area file (*.ARE *.are *.afs)"));
QStringList files;
if (fd.exec () == QDialog::Accepted)
{
// Save the directory that we were in when we selected a file.
pfm_global->area_dir = fd.directory ().absolutePath ();
files = fd.selectedFiles ();
pfm_def->area = files.at (0);
if (!pfm_def->area.isEmpty())
{
area_edit->setText (pfm_def->area);
if (!pfm_file_edit->text ().isEmpty () && !area_edit->text ().isEmpty ()) setButtonText (QWizard::NextButton, tr ("Next"));
}
}
}
示例8: OpenExistingProject
//-----------------------------------------------------------------------------
void EdProjectManager::OpenExistingProject()
{
this->MaybeSaveCurrentProject();
QFileDialog dialog;
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(TR("Project files (*"ED_PROJECT_FILE_EXTENSION")"));
static QString prevDirectory = EdSystem::Get().settings.pathToProjects;
dialog.setDirectory(prevDirectory);
if (dialog.exec())
{
prevDirectory = dialog.directory().path();
QStringList files = dialog.selectedFiles();
Assert(files.count()==1);
this->OpenProjectFile( files.first().toAscii().data() );
}
}
示例9: OnDataSelChanged
void BackendSelector::OnDataSelChanged(int index)
{
if(index == -1)
return;
QVariant var = m_data_selector->itemData(index);
if(var == DataSelFile)
{
m_data_sel_edit->show();
#ifdef HAVE_HWSTUB
m_dev_selector->hide();
#endif
QFileDialog *fd = new QFileDialog(m_data_selector);
fd->setFilter("Textual files (*.txt);;All files (*)");
fd->setDirectory(Settings::Get()->value("loaddatadir", QDir::currentPath()).toString());
if(fd->exec())
{
QStringList filenames = fd->selectedFiles();
ChangeBackend(m_backend->CreateFileIoBackend(filenames[0]));
m_data_sel_edit->setText(filenames[0]);
}
Settings::Get()->setValue("loaddatadir", fd->directory().absolutePath());
}
#ifdef HAVE_HWSTUB
else if(var == DataSelDevice)
{
m_data_sel_edit->hide();;
m_dev_selector->show();
OnDevListChanged();
}
#endif
else
{
m_data_sel_edit->hide();
#ifdef HAVE_HWSTUB
m_dev_selector->hide();
#endif
ChangeBackend(m_backend->CreateDummyIoBackend());
}
}
示例10: actionSaveAs
void MainWindow::actionSaveAs()
{
ModelInfo tmpModelinfo(m_modelinfo);
QStringList filters;
filters << "PIE3 models (*.pie)" << "PIE2 models (*.pie)" << "WZM models (*.wzm)" << "OBJ files (*.obj)";
QList<wmit_filetype_t> types;
types << WMIT_FT_PIE << WMIT_FT_PIE2 << WMIT_FT_WZM << WMIT_FT_OBJ;
QFileDialog* fDialog = new QFileDialog();
fDialog->setFileMode(QFileDialog::AnyFile);
fDialog->setAcceptMode(QFileDialog::AcceptSave);
fDialog->setNameFilters(filters);
fDialog->setWindowTitle(tr("Choose output file"));
fDialog->setDirectory(m_pathExport);
fDialog->exec();
if (fDialog->result() != QDialog::Accepted)
{
return;
}
if (!filters.contains(fDialog->selectedNameFilter()))
{
return;
}
tmpModelinfo.m_save_type = types[filters.indexOf(fDialog->selectedNameFilter())];
// refresh export working dir
m_pathExport = fDialog->directory().absolutePath();
m_settings->setValue(WMIT_SETTINGS_EXPORTVAL, m_pathExport);
QFileInfo finfo(fDialog->selectedFiles().first());
tmpModelinfo.m_saveAsFile = finfo.filePath();
QPointer<ExportDialog> dlg;
switch (tmpModelinfo.m_save_type)
{
case WMIT_FT_PIE:
case WMIT_FT_PIE2:
tmpModelinfo.defaultPieCapsIfNeeded();
dlg = new PieExportDialog(tmpModelinfo.m_pieCaps, this);
if (dlg->exec() == QDialog::Accepted)
{
tmpModelinfo.m_pieCaps = static_cast<PieExportDialog*>(dlg.data())->getCaps();
}
if (finfo.suffix().toLower() != "pie")
tmpModelinfo.m_saveAsFile += ".pie";
break;
case WMIT_FT_OBJ:
if (finfo.suffix().toLower() != "obj")
tmpModelinfo.m_saveAsFile += ".obj";
break;
case WMIT_FT_WZM:
if (finfo.suffix().toLower() != "wzm")
tmpModelinfo.m_saveAsFile += ".wzm";
break;
}
if (dlg && dlg->result() != QDialog::Accepted)
{
return;
}
m_modelinfo = tmpModelinfo;
PrependFileToRecentList(m_modelinfo.m_saveAsFile);
saveModel(m_model, m_modelinfo);
}
示例11: 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;
}
}
示例12: slotTxtFileBrowse
void mosaicPage::slotTxtFileBrowse ()
{
QStringList files, filters;
QString file;
QFileDialog *fd = new QFileDialog (this, tr ("pfmChartsImage Select Mission Parameters File"));
fd->setViewMode (QFileDialog::List);
// Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
// This function is in the nvutility library.
setSidebarUrls (fd, options->param_dir);
filters << tr ("Text (*.txt)");
fd->setFilters (filters);
fd->setFileMode (QFileDialog::ExistingFile);
fd->selectFilter (tr ("Text (*.txt)"));
if (fd->exec () == QDialog::Accepted)
{
files = fd->selectedFiles ();
QString txt_file_name = files.at (0);
if (!txt_file_name.isEmpty())
{
txt_file_edit->setText (txt_file_name);
NV_CHAR txt_file[512];
strcpy (txt_file, txt_file_name.toAscii ());
FILE *fp;
if ((fp = fopen (txt_file, "r")) == NULL)
{
QMessageBox::warning (this, tr ("Select Mission Parameters File"),
tr ("The file ") + txt_file_name +
tr (" could not be opened.") +
tr (" The error message returned was:\n\n") +
QString (strerror (errno)));
return;
}
NV_CHAR string[128];
NV_FLOAT64 roll_bias = 0.0, pitch_bias = 0.0, heading_bias = 0.0, pixel_size = 0.0, focal_length = 0.0,
col_offset = 0.0, row_offset = 0.0, time_delay = 0.0;
NV_INT32 ms;
while (fgets (string, sizeof (string), fp) != NULL)
{
if (strstr (string, "camera_boresight_roll:"))
sscanf (string, "camera_boresight_roll: %lf", &roll_bias);
if (strstr (string, "camera_boresight_pitch:"))
sscanf (string, "camera_boresight_pitch: %lf", &pitch_bias);
if (strstr (string, "camera_boresight_heading:"))
sscanf (string, "camera_boresight_heading: %lf", &heading_bias);
if (strstr (string, "pixel_size:"))
sscanf (string, "pixel_size: %lf", &pixel_size);
if (strstr (string, "focal_length:"))
sscanf (string, "focal_length: %lf", &focal_length);
if (strstr (string, "principal_point_offsets:"))
sscanf (string, "principal_point_offsets: %lf, %lf", &col_offset, &row_offset);
if (strstr (string, "camera_trig_delay:"))
{
sscanf (string, "camera_trig_delay: %d", &ms);
time_delay = (NV_FLOAT64) ms / 1000.0;
}
}
fclose (fp);
timeSpin->setValue (time_delay);
rollSpin->setValue (roll_bias);
pitchSpin->setValue (pitch_bias);
headingSpin->setValue (heading_bias);
focalSpin->setValue (focal_length);
pixelSpin->setValue (pixel_size);
colSpin->setValue (col_offset);
rowSpin->setValue (row_offset);
}
options->param_dir = fd->directory ().absolutePath ();
}
}
示例13: generateVASP_POTCAR_info
bool TabEdit::generateVASP_POTCAR_info()
{
XtalOpt *xtalopt = qobject_cast<XtalOpt*>(m_opt);
QSettings settings; // Already set up in avogadro/src/main.cpp
QString path = settings.value("xtalopt/templates/potcarPath", "").toString();
QVariantList potcarInfo;
// Generate list of symbols
QList<QString> symbols;
QList<uint> atomicNums = xtalopt->comp.keys();
qSort(atomicNums);
for (int i = 0; i < atomicNums.size(); i++)
symbols.append(OpenBabel::etab.GetSymbol(atomicNums.at(i)));
qSort(symbols);
QStringList files;
QString filename;
QVariantHash hash;
for (int i = 0; i < symbols.size(); i++) {
QString path = settings.value("xtalopt/templates/potcarPath", "").toString();
QFileDialog dialog (NULL, QString("Select pot file for atom %1").arg(symbols.at(i)), path);
dialog.selectFile(path + "/" + symbols.at(i));
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec()) {
files = dialog.selectedFiles();
if (files.size() != 1) { // Ask again!
i--;
continue;
}
filename = files.first();
settings.setValue("xtalopt/templates/potcarPath", dialog.directory().absolutePath());
}
else {
// User cancel file selection. Set template selection combo to
// something else so the list will remain empty and be
// detected when the search starts. Ref ticket 79.
int curInd = ui_combo_templates->currentIndex();
int maxInd = ui_combo_templates->count() - 1;
int newInd = (curInd == maxInd) ? 0 : maxInd;
ui_combo_templates->setCurrentIndex(newInd);
return false;
}
hash.insert(symbols.at(i), QVariant(filename));
}
for (int i = 0; i < m_opt->optimizer()->getNumberOfOptSteps(); i++) {
potcarInfo.append(QVariant(hash));
}
// Set composition in optimizer
QVariantList toOpt;
for (int i = 0; i < atomicNums.size(); i++) {
toOpt.append(atomicNums.at(i));
}
m_opt->optimizer()->setData("Composition", toOpt);
// Set POTCAR info
m_opt->optimizer()->setData("POTCAR info", QVariant(potcarInfo));
updateEditWidget();
return true;
}