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


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

本文整理汇总了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)));
}
开发者ID:Skycoder42,项目名称:IcoDroid,代码行数:31,代码来源:mainwindow.cpp

示例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()));
}
开发者ID:adaptee,项目名称:fcitx,代码行数:8,代码来源:editor.cpp

示例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()));
}
开发者ID:AndKe,项目名称:apm_planner,代码行数:8,代码来源:PresetManager.cpp

示例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()));
}
开发者ID:amitkr,项目名称:apm_planner,代码行数:16,代码来源:ParamCompareDialog.cpp

示例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);
    }
开发者ID:svn2github,项目名称:virtualbox,代码行数:67,代码来源:QIFileDialog.cpp

示例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
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:101,代码来源:QIFileDialog.cpp


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