本文整理汇总了C++中QFileDialog::getOpenFileUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::getOpenFileUrl方法的具体用法?C++ QFileDialog::getOpenFileUrl怎么用?C++ QFileDialog::getOpenFileUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::getOpenFileUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int ac, char **av)
{
QApplication app(ac, av);
Qt3DExtras::Qt3DWindow view;
view.defaultFrameGraph()->setClearColor(Qt::black);
// Root entity
Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity();
// Scene Camera
Qt3DRender::QCamera *camera = view.camera();
camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection);
camera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f));
camera->setPosition(QVector3D(0.0f, 3.5f, 25.0f));
camera->setNearPlane(0.001f);
camera->setFarPlane(10000.0f);
// For camera controls
Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot);
camController->setCamera(camera);
// Scene loader
Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot);
Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity);
SceneWalker sceneWalker(sceneLoader);
QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, &sceneWalker, &SceneWalker::onStatusChanged);
sceneLoaderEntity->addComponent(sceneLoader);
QStringList args = QCoreApplication::arguments();
QUrl sourceFileName;
if (args.count() <= 1) {
QWidget *container = new QWidget();
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
sourceFileName = dialog.getOpenFileUrl(container, QStringLiteral("Open a scene file"));
} else {
sourceFileName = QUrl::fromLocalFile(args[1]);
}
if (sourceFileName.isEmpty())
return 0;
sceneLoader->setSource(sourceFileName);
view.setRootEntity(sceneRoot);
view.show();
return app.exec();
}