本文整理汇总了C++中QQuickView::setGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickView::setGeometry方法的具体用法?C++ QQuickView::setGeometry怎么用?C++ QQuickView::setGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickView
的用法示例。
在下文中一共展示了QQuickView::setGeometry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QGuiApplication application(argc, argv);
const QString mainQmlApp = QStringLiteral("qrc:///flickr.qml");
QQuickView view;
view.setSource(QUrl(mainQmlApp));
view.setResizeMode(QQuickView::SizeRootObjectToView);
// Qt.quit() called in embedded .qml by default only emits
// quit() signal, so do this (optionally use Qt.exit()).
QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
view.setGeometry(QRect(100, 100, 360, 640));
view.show();
return application.exec();
}
示例2: main
int main(int argc, char *argv[])
{
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
QGuiApplication application(argc, argv);
const QString mainQmlApp(QStringLiteral("qrc:/btcontrol.qml"));
QQuickView view;
view.setSource(QUrl(mainQmlApp));
view.setResizeMode(QQuickView::SizeRootObjectToView);
// Qt.quit() called in embedded .qml by default only emits
// quit() signal, so do this (optionally use Qt.exit()).
QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
//view.setGeometry(QRect(100, 100, 360, 640));
view.setGeometry(QRect(100, 100, 600, 800));
view.show();
return application.exec();
}
示例3: main
//.........这里部分代码省略.........
qmlRegisterUncreatableType<Trainrestrictions>("Fahrplan", 1, 0, "Trainrestrictions"
, "Trainrestrictions cannot be created from QML. "
"Access it through FahrplanBackend.trainrestrictions.");
qmlRegisterUncreatableType<Backends>("Fahrplan", 1, 0, "Backends"
, "Backends cannot be created from QML. "
"Access it through FahrplanBackend.backends.");
qmlRegisterType<JourneyResultList>("Fahrplan", 1, 0, "JourneyResultList");
qmlRegisterType<JourneyResultItem>("Fahrplan", 1, 0, "JourneyResultItem");
qmlRegisterType<JourneyDetailResultList>("Fahrplan", 1, 0, "JourneyDetailResultList");
qmlRegisterType<JourneyDetailResultItem>("Fahrplan", 1, 0, "JourneyDetailResultItem");
#if defined(BUILD_FOR_SAILFISHOS)
QQuickView *view = SailfishApp::createView();
#elif defined(HAVE_DECLARATIVE_CACHE)
QDeclarativeView* view = MDeclarativeCache::qDeclarativeView();
#elif defined(BUILD_FOR_QT5)
QQuickView *view = new QQuickView();
#else
QDeclarativeView* view = new QDeclarativeView();
#endif
#if defined(BUILD_FOR_HARMATTAN)
qDebug()<<"Harmattan";
view->setSource(QUrl("qrc:/src/gui/harmattan/main.qml"));
view->showFullScreen();
#elif defined(BUILD_FOR_MAEMO_5)
qDebug()<<"Maemo5";
qmlRegisterType<HildonHelper>("HildonHelper", 1, 0, "HildonHelper");
view->setSource(QUrl("qrc:/src/gui/fremantle/main.qml"));
view->show();
#elif defined(BUILD_FOR_SYMBIAN)
qDebug()<<"Symbian";
view->setSource(QUrl("qrc:/src/gui/symbian/main.qml"));
view->showFullScreen();
#elif defined(BUILD_FOR_UBUNTU)
qDebug()<<"Ubuntu";
view->setSource(QUrl("qrc:/src/gui/ubuntu/main.qml"));
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->show();
QSettings settings(FAHRPLAN_SETTINGS_NAMESPACE, "fahrplan2");
view->setGeometry(settings.value("geometry", QRect(100, 100, 400, 600)).toRect());
#elif defined(BUILD_FOR_SAILFISHOS)
qDebug()<<"SailfishOs";
view->setSource(QUrl("qrc:/src/gui/sailfishos/main.qml"));
view->showFullScreen();
#elif defined(BUILD_FOR_BLACKBERRY)
qDebug() << "Blackberry";
// QML wrapper around Qt Mobility Subset
qmlRegisterType<QtMobilitySubset::BlackBerryPositionSource>("QtMobility.location", 1, 1, "PositionSource");
qmlRegisterUncreatableType<QtMobilitySubset::BlackBerryPosition>("QtMobility.location", 1, 1, "Position", "Cant't create Position type");
qmlRegisterUncreatableType<QtMobilitySubset::BlackBerryCoordinate>("QtMobility.location", 1, 1, "Coordinate", "Cant't create Coordinate type");
QSettings *settings = new QSettings(FAHRPLAN_SETTINGS_NAMESPACE, "fahrplan2");
// Check if GPS Location permission is set
// and geolocation services are enabled.
int res = geolocation_request_events(0);
if (res == BPS_SUCCESS)
geolocation_stop_events(0);
settings->setValue("enableGps", res == BPS_SUCCESS);
delete settings;
// Improves touch handling
QApplication::setStartDragDistance(42);
QGLWidget *gl = new QGLWidget();
view->setViewport(gl);
view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
view->setSource(QUrl("qrc:/src/gui/symbian/main.qml"));
// Hide Symbian-style status bar on BlackBerry
view->rootObject()->setProperty("showStatusBar", false);
view->showFullScreen();
#endif
#else
qDebug()<<"Desktop";
MainWindow w;
w.show();
#endif
qDebug()<<"Exec";
int error = app->exec();
#if defined(BUILD_FOR_UBUNTU)
settings.setValue("geometry", view->geometry());
#endif
#ifndef Q_OS_BLACKBERRY
// For some reason, this causes a weird freeze of
// Fahrplan on BlackBerry 10 so that it can only
// be closed by restarting the phone.
delete app;
#endif
return error;
}
示例4: main
int main(int argc, char **argv) {
QStringList arguments;
for(int ii = 0; ii < argc; ii++) {
arguments << argv[ii];
}
if ( arguments.indexOf("--help") > 0 || arguments.indexOf("-h") > 0 ) {
showUsageHelp(argv[0]);
return 1;
}
#ifdef USE_QT5
// install message handler
qInstallMessageHandler(SDDM::MessageHandler);
// create application
QGuiApplication app(argc, argv);
// create view
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
#else
// create application
QApplication app(argc, argv);
// create view
QDeclarativeView view;
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
#endif
view.engine()->addImportPath(IMPORTS_INSTALL_DIR);
// create configuration instance
Configuration configuration(CONFIG_FILE);
// get socket name
QString socket = parameter(app.arguments(), "--socket", "");
// get theme path
QString theme = parameter(app.arguments(), "--theme", "");
// read theme metadata
ThemeMetadata metadata(QString("%1/metadata.desktop").arg(theme));
// get theme config file
QString configFile = QString("%1/%2").arg(theme).arg(metadata.configFile());
// read theme config
ThemeConfig config(configFile);
// create models
SessionModel sessionModel;
ScreenModel screenModel;
UserModel userModel;
GreeterProxy proxy(socket);
proxy.setSessionModel(&sessionModel);
// set context properties
view.rootContext()->setContextProperty("sessionModel", &sessionModel);
view.rootContext()->setContextProperty("screenModel", &screenModel);
view.rootContext()->setContextProperty("userModel", &userModel);
view.rootContext()->setContextProperty("config", config);
view.rootContext()->setContextProperty("sddm", &proxy);
// connect proxy signals
QObject::connect(&proxy, SIGNAL(loginSucceeded()), &view, SLOT(close()));
// get theme main script
QString mainScript = QString("%1/%2").arg(theme).arg(metadata.mainScript());
// set main script as source
view.setSource(QUrl::fromLocalFile(mainScript));
// show view
view.showFullScreen();
view.setGeometry(screenModel.geometry());
// run application
return app.exec();
}
示例5: addViewForScreen
void GreeterApp::addViewForScreen(QScreen *screen) {
// create view
QQuickView *view = new QQuickView();
view->setScreen(screen);
view->setResizeMode(QQuickView::SizeRootObjectToView);
//view->setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
view->setGeometry(screen->geometry());
m_views.append(view);
// remove the view when the screen is removed, but we
// need to be careful here since Qt will move the view to
// another screen before this signal is emitted so we
// pass a pointer to the view to our slot
connect(this, &GreeterApp::screenRemoved, this, [view, this](QScreen *) {
removeViewForScreen(view);
});
// always resize when the screen geometry changes
connect(screen, &QScreen::geometryChanged, this, [view](const QRect &r) {
view->setGeometry(r);
});
view->engine()->addImportPath(QStringLiteral(IMPORTS_INSTALL_DIR));
// connect proxy signals
connect(m_proxy, SIGNAL(loginSucceeded()), view, SLOT(close()));
// we used to have only one window as big as the virtual desktop,
// QML took care of creating an item for each screen by iterating on
// the screen model. However we now have a better approach: we create
// a view for each screen that compose the virtual desktop and thus
// the QML code for each screen is responsible for drawing only its
// screen. By doing so we actually make the screen model useless, but
// we want to keep it for compatibility reasons, we do however create
// one for each view and expose only the screen that the view belongs to
// in order to avoid creating items with different sizes.
ScreenModel *screenModel = new ScreenModel(screen, view);
// set context properties
view->rootContext()->setContextProperty(QStringLiteral("sessionModel"), m_sessionModel);
view->rootContext()->setContextProperty(QStringLiteral("screenModel"), screenModel);
view->rootContext()->setContextProperty(QStringLiteral("userModel"), m_userModel);
view->rootContext()->setContextProperty(QStringLiteral("config"), *m_themeConfig);
view->rootContext()->setContextProperty(QStringLiteral("sddm"), m_proxy);
view->rootContext()->setContextProperty(QStringLiteral("keyboard"), m_keyboard);
view->rootContext()->setContextProperty(QStringLiteral("primaryScreen"), QGuiApplication::primaryScreen() == screen);
view->rootContext()->setContextProperty(QStringLiteral("__sddm_errors"), QString());
// get theme main script
QString mainScript = QStringLiteral("%1/%2").arg(m_themePath).arg(m_metadata->mainScript());
QUrl mainScriptUrl;
if (m_themePath.startsWith(QLatin1String("qrc:/")))
mainScriptUrl = QUrl(mainScript);
else
mainScriptUrl = QUrl::fromLocalFile(mainScript);
// load theme from resources when an error has occurred
connect(view, &QQuickView::statusChanged, this, [view](QQuickView::Status status) {
if (status != QQuickView::Error)
return;
QString errors;
Q_FOREACH(const QQmlError &e, view->errors()) {
qWarning() << e;
errors += QLatin1String("\n") + e.toString();
}
qWarning() << "Fallback to embedded theme";
view->rootContext()->setContextProperty(QStringLiteral("__sddm_errors"), errors);
view->setSource(QUrl(QStringLiteral("qrc:/theme/Main.qml")));
});