本文整理汇总了C++中QFileDialog::open方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::open方法的具体用法?C++ QFileDialog::open怎么用?C++ QFileDialog::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)));
}
示例2: exportData
void ListEditor::exportData()
{
QFileDialog* dialog = new QFileDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->open();
connect(dialog, SIGNAL(accepted()), this, SLOT(exportFileSelected()));
}
示例3: loadPresets
void PresetManager::loadPresets()
{
checkAndSaveIfPresetModified();
QFileDialog *dialog = new QFileDialog(qobject_cast<QWidget*>(parent()), "Load Analyzing Presets", QGC::appDataDirectory(), "Analyzing Presets (*.ini);;All Files (*.*)");
dialog->setFileMode(QFileDialog::ExistingFile);
dialog->open(this, SLOT(loadDialogAccepted()));
}
示例4: showLoadFileDialog
void ParamCompareDialog::showLoadFileDialog()
{
ui->compareTableWidget->setRowCount(0);
QDir parameterDir = QDir(QGC::parameterDirectory());
if(!parameterDir.exists())
parameterDir.mkdir(parameterDir.path());
QFileDialog *fileDialog = new QFileDialog(this,"Load",QGC::parameterDirectory());
QLOG_DEBUG() << "CREATED:" << fileDialog;
fileDialog->setFileMode(QFileDialog::ExistingFile);
fileDialog->setNameFilter("*.param *.txt");
fileDialog->open(this, SLOT(loadParameterFile()));
connect(fileDialog,SIGNAL(rejected()),SLOT(dialogRejected()));
}
示例5: getOpenFileNames
//.........这里部分代码省略.........
// qt_win_eatMouseMove();
MSG msg = {0, 0, 0, 0, 0, 0, 0};
while (PeekMessage (&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
if (msg.message == WM_MOUSEMOVE)
PostMessage (msg.hwnd, msg.message, 0, msg.lParam);
result = result.isEmpty() ? result : QFileInfo (result).absoluteFilePath();
QApplication::postEvent (mTarget, new GetOpenFileNameEvent (result));
}
private:
QWidget *mParent;
QObject *mTarget;
QString mStartWith;
QString mFilters;
QString mCaption;
};
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);
openDirThread.start();
loop.exec();
openDirThread.wait();
if (aParent)
aParent->setWindowModality (Qt::NonModal);
return QStringList() << 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);
if (aSingleFile)
dlg.setFileMode (QFileDialog::ExistingFile);
else
dlg.setFileMode (QFileDialog::ExistingFiles);
if (aSelectedFilter)
dlg.selectFilter (*aSelectedFilter);
dlg.setResolveSymlinks (aResolveSymlinks);
QAction *hidden = dlg.findChild <QAction*> ("qt_show_hidden_action");
if (hidden)
{
hidden->trigger();
hidden->setVisible (false);
}
示例6: getExistingDirectory
//.........这里部分代码省略.........
bi.lpfn = winGetExistDirCallbackProc;
bi.lParam = uintptr_t(&mDir);
LPITEMIDLIST itemIdList = SHBrowseForFolder (&bi);
if (itemIdList)
{
SHGetPathFromIDList (itemIdList, path);
IMalloc *pMalloc;
if (SHGetMalloc (&pMalloc) != NOERROR)
result = QString::null;
else
{
pMalloc->Free (itemIdList);
pMalloc->Release();
result = QString::fromUtf16 ((ushort*)path);
}
}
else
result = QString::null;
QApplication::postEvent (mTarget, new GetExistDirectoryEvent (result));
}
private:
QWidget *mParent;
QObject *mTarget;
QString mDir;
QString mCaption;
};
/* Local event loop to run while waiting for the result from another
* thread */
QEventLoop loop;
QString dir = QDir::toNativeSeparators (aDir);
LoopObject loopObject ((QEvent::Type) GetExistDirectoryEvent::TypeId, loop);
Thread openDirThread (aParent, &loopObject, dir, aCaption);
openDirThread.start();
loop.exec();
openDirThread.wait();
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 (aDir);
dlg.setResolveSymlinks (aResolveSymlinks);
dlg.setFileMode (aDirOnly ? QFileDialog::DirectoryOnly : QFileDialog::Directory);
QAction *hidden = dlg.findChild <QAction*> ("qt_show_hidden_action");
if (hidden)
{
hidden->trigger();
hidden->setVisible (false);
}
return dlg.exec() ? dlg.selectedFiles() [0] : QString::null;
#elif defined (VBOX_WS_MAC) && (QT_VERSION >= 0x040600)
/* 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);
dlg.setDirectory(aDir);
dlg.setResolveSymlinks(aResolveSymlinks);
dlg.setFileMode(aDirOnly ? QFileDialog::DirectoryOnly : QFileDialog::Directory);
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 (aDirOnly)
o |= QFileDialog::ShowDirsOnly;
if (!aResolveSymlinks)
o |= QFileDialog::DontResolveSymlinks;
return QFileDialog::getExistingDirectory (aParent, aCaption, aDir, o);
#endif
}