本文整理汇总了C++中QQuickView::rootContext方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickView::rootContext方法的具体用法?C++ QQuickView::rootContext怎么用?C++ QQuickView::rootContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickView
的用法示例。
在下文中一共展示了QQuickView::rootContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
QDialog(parent)
{
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
qmlRegisterType<UAVOLogSettingsWrapper>("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
setWindowTitle(tr("Manage flight side logs"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setMinimumSize(600, 400);
QQuickView *view = new QQuickView();
view->rootContext()->setContextProperty("dialog", this);
view->rootContext()->setContextProperty("logStatus", flightLogManager->flightLogStatus());
view->rootContext()->setContextProperty("logControl", flightLogManager->flightLogControl());
view->rootContext()->setContextProperty("logSettings", flightLogManager->flightLogSettings());
view->rootContext()->setContextProperty("logManager", flightLogManager);
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
QWidget *container = QWidget::createWindowContainer(view);
container->setMinimumSize(600, 400);
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *lay = new QVBoxLayout();
lay->setContentsMargins(0, 0, 0, 0);
setLayout(lay);
layout()->addWidget(container);
}
示例2: main
Q_DECL_EXPORT int main(int argc, char *argv[]) {
QGuiApplication *lApplication = new QGuiApplication(argc, argv);
QQuickView *lView = new QQuickView;
lView->setResizeMode(QQuickView::SizeRootObjectToView);
QVariantList lLevelList;
createAllLevels(lLevelList);
lView->rootContext()->setContextProperty(QStringLiteral("gLevels"), lLevelList);
QNetworkAccessManager lNetworkManager;
LevelModel *lLevelModel = new LevelModel(lLevelList.count(), &lNetworkManager, lApplication);
lView->rootContext()->setContextProperty(QStringLiteral("gLevelModel"), lLevelModel);
HighScoresModel *lHighScoresModel = new HighScoresModel(lApplication);
lView->rootContext()->setContextProperty(QStringLiteral("gHighScoresModel"), lHighScoresModel);
QObject::connect(lLevelModel, SIGNAL(postingSucceded()), lHighScoresModel, SLOT(readScoresFromFile()));
QObject::connect(lView->engine(), SIGNAL(quit()), lApplication, SLOT(quit()));
qmlRegisterType<LevelHighScoresModel>("ChimpModels", 1, 0, "LevelHighScoreModel");
LevelHighScoresModel::registerOtherModels(lLevelModel, lHighScoresModel);
lView->setSource(QStringLiteral("qrc:///qml/Game.qml"));
lView->showFullScreen();
return lApplication->exec();
}
示例3: main
int main(int argc, char *argv[]) {
QGuiApplication* app = SailfishApp::application(argc, argv);
QQuickView* view = SailfishApp::createView();
Configurator config;
config.load();
//qmlRegisterType<Request>("Sailbook.Request", 1, 0, "Request");
qmlRegisterUncreatableType<Request>("App.Sailbook", 1, 0, "Request", QStringLiteral("Error"));
//qmlRegisterInterface<SessionManager>("SessionManager");
SessionManager session(QStringLiteral(APPID), config.getValue(QStringLiteral("token")).toString());
session.setExtendedPermission(SessionManager::ExtendedPermissions(
SessionManager::Email |
SessionManager::ManageNotifications |
SessionManager::ManagePages |
SessionManager::PublishActions |
SessionManager::ReadFriendList |
SessionManager::ReadInsights |
SessionManager::ReadMailbox |
SessionManager::ReadPageMailboxes |
SessionManager::ReadStream |
SessionManager::RsvpEvent
));
session.setUserDataPermission(SessionManager::UserDataPermissions(
SessionManager::UserAboutMe |
SessionManager::UserActionsBooks |
SessionManager::UserActionsMusic |
SessionManager::UserActionsNews |
SessionManager::UserActionsVideo |
SessionManager::UserActivities |
SessionManager::UserBirthday |
SessionManager::UserEducationHistory |
SessionManager::UserEvents |
SessionManager::UserFriends |
SessionManager::UserGamesActivity |
SessionManager::UserGroups |
SessionManager::UserHometown |
SessionManager::UserInterests |
SessionManager::UserLikes |
SessionManager::UserLocation |
SessionManager::UserPhotos |
SessionManager::UserRelationshipDetails |
SessionManager::UserRelationships |
SessionManager::UserReligionPolitics |
SessionManager::UserStatus |
SessionManager::UserTaggedPlaces |
SessionManager::UserVideos |
SessionManager::UserWebsite |
SessionManager::UserWorkHistory
));
view->rootContext()->setContextProperty("SessionManager", &session);
view->rootContext()->setContextProperty("Configurator", &config);
view->setSource(SailfishApp::pathTo("qml/sailbook.qml"));
view->show();
return app->exec();
}
示例4: main
int main(int argc, char *argv[])
{
//start appliacation
QGuiApplication a(argc, argv);
//settings
CQmlSettings settings(QCoreApplication::applicationDirPath() + "/qmlConfigure.xml");
if(settings.errorMap.count() > 0)
exit(0);
DVRSettings dvrSetting;
dvrSetting.IP = settings.node("IP");
dvrSetting.server_port = settings.node("serverPort").toInt();
//事物层对象初始化
CTransaction transaction;
//初始化clientThread
ClientThread receiveDataThread(&transaction, dvrSetting);
receiveDataThread.start();
QQuickView view;
view.rootContext()->setContextProperty("transaction", &transaction);
view.rootContext()->setContextProperty("settings", &settings);
view.rootContext()->setContextProperty("mainWindow", &view);
view.setSource(QUrl("qrc:/robo/qml/hitRobotGroup/MainPage.qml"));
view.show();
return a.exec();
}
示例5: main
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
// qmlRegisterType<TraceView>("SysViz", 1, 0, "TraceView");
qmlRegisterType<ThreadSliceView>("SysViz", 1, 0, "ThreadSliceView");
qmlRegisterType<GraphItem> ("SysViz", 1, 0, "GraphItem");
qmlRegisterType<TraceModel>();
qmlRegisterType<QAbstractListModel>();
qmlRegisterType<CpuFrequencyModel>();
qmlRegisterType<GpuFrequencyModel>();
TraceModel model;
QQuickView view;
QSurfaceFormat format = view.requestedFormat();
format.setSamples(16);
view.setFormat(format);
view.rootContext()->setContextProperty("traceModel", &model);
view.rootContext()->setContextProperty("cm", view.screen()->physicalDotsPerInch() / 2.54);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl::fromLocalFile("qml/main.qml"));
view.setTitle("sysviz");
view.show();
#ifdef QT_DQML_LIB
DQmlLocalServer server(view.engine(), &view, "qml/main.qml");
server.fileTracker()->track("qml", "qml");
#endif
app.exec();
}
示例6: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQuickView viewer;
viewer.setResizeMode(QQuickView::SizeRootObjectToView);
QObjectList model_qobjectlist;
model_qobjectlist << new TestObject(0);
model_qobjectlist << new TestObject(1);
model_qobjectlist << new TestObject(2);
viewer.rootContext()->setContextProperty("model_qobjectlist", QVariant::fromValue(model_qobjectlist));
TestObject *model_qobject = new TestObject(0);
viewer.rootContext()->setContextProperty("model_qobject", QVariant::fromValue(model_qobject));
QStringList model_qstringlist;
model_qstringlist << QStringLiteral("A");
model_qstringlist << QStringLiteral("B");
model_qstringlist << QStringLiteral("C");
viewer.rootContext()->setContextProperty("model_qstringlist", model_qstringlist);
TestModel *model_qaim = new TestModel;
viewer.rootContext()->setContextProperty("model_qaim", model_qaim);
viewer.setSource(QStringLiteral("qrc:/qml/main.qml"));
viewer.show();
return app.exec();
}
示例7: main
int main(int argc, char *argv[])
{
QProcess appinfo;
QString appversion;
QString appname = "TaskList";
QString pkgname = "harbour-tasklist";
QCoreApplication::setOrganizationName(pkgname);
QCoreApplication::setApplicationName(pkgname);
// read app version from rpm database on startup
appinfo.start("/bin/rpm", QStringList() << "-qa" << "--queryformat" << "%{version}" << pkgname);
appinfo.waitForFinished(-1);
if (appinfo.bytesAvailable() > 0) {
appversion = appinfo.readAll();
}
/* Internationalization Support
thanks to Antoine Reversat who mentioned this here:
https://www.mail-archive.com/[email protected]/msg02602.html */
QGuiApplication* app = SailfishApp::application(argc, argv);
// load default translator and system locale's translator afterwards
QTranslator defaultTranslator;
defaultTranslator.load("en_US", SailfishApp::pathTo(QString("localization")).toLocalFile());
app->installTranslator(&defaultTranslator);
QSettings settings;
QString locale = settings.value("language", "").toString();
if (locale.isEmpty() || locale == QString("system_default")) {
/* use system locale by default */
if (locale.isEmpty())
settings.setValue("language", "system_default");
locale = QLocale::system().name();
}
QTranslator translator;
translator.load(locale, SailfishApp::pathTo(QString("localization")).toLocalFile());
app->installTranslator(&translator);
qmlRegisterType<TasksExport>("harbour.tasklist.tasks_export", 1, 0, "TasksExport");
QQuickView* view = SailfishApp::createView();
QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));
view->rootContext()->setContextProperty("version", appversion);
view->rootContext()->setContextProperty("appname", appname);
view->setSource(SailfishApp::pathTo("qml/harbour-tasklist.qml"));
view->show();
return app->exec();
}
示例8: main
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QQuickView view;
XHR* xhr = XHR::instance();
view.rootContext()->setContextProperty("xhr", xhr);
FILESYSTEM* filesystem = FILESYSTEM::instance();
view.rootContext()->setContextProperty("filesystem", filesystem);
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
view.show();
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
return app.exec();
}
示例9: main
int main(int argc, char *argv[])
{
QApplication qapp(argc, argv);
QQuickView *qtstudy = new QQuickView;
Pastebin *pastebin = new Pastebin;
qtstudy->rootContext()->setContextProperty("qapp", &qapp);
qtstudy->rootContext()->setContextProperty("qpastebin", pastebin);
qtstudy->setSource(QUrl("qrc:/qml/qtstudy.qml"));
qtstudy->show();
return qapp.exec();
}
示例10: main
//![0]
int main(int argc, char ** argv)
{
QGuiApplication app(argc, argv);
QList<QObject*> dataList;
dataList.append(new DataObject("Item 1", "red"));
dataList.append(new DataObject("Item 2", "green"));
dataList.append(new DataObject("Item 3", "blue"));
dataList.append(new DataObject("Item 4", "yellow"));
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
QQmlContext *ctxt = view.rootContext();
//![0]
#if 1
// add precompiled files
QQmlEngine *engine = view.engine();
QQmlEnginePrivate::get(engine)->v4engine()->iselFactory.reset(new QV4::JIT::ISelFactory);
QmcLoader loader(engine);
QQmlComponent *component = loader.loadComponent(":/view.qmc");
if (!component) {
qDebug() << "Could not load component";
return -1;
}
if (!component->isReady()) {
qDebug() << "Component is not ready";
if (component->isError()) {
foreach (const QQmlError &error, component->errors()) {
qDebug() << error.toString();
}
}
示例11: run
void ZLibrary::run(ZLApplication* aApp)
{
if (ZLLanguageUtil::isRTLLanguage(ZLibrary::Language())) {
qApp->setLayoutDirection(Qt::RightToLeft);
}
QString qml(QString::fromStdString(BaseDirectory + BOOKS_QML_FILE));
HDEBUG("qml file" << qPrintable(qml));
QQuickView* view = SailfishApp::createView();
QQmlContext* root = view->rootContext();
QSize screenSize(view->screen()->size());
booksPPI =
#if defined(__i386__)
(screenSize == QSize(1536,2048)) ? 330 : 300;
#elif defined(__arm__)
(screenSize == QSize(540,960)) ? 245 : 290;
#else
# error Unexpected architechture
#endif
HDEBUG("screen" << screenSize << booksPPI << "dpi");
root->setContextProperty("PointsPerInch", booksPPI);
root->setContextProperty("MaximumHintCount", 1);
view->setTitle(qtTrId("books-app-name"));
view->setSource(QUrl::fromLocalFile(qml));
view->show();
HDEBUG("started");
qApp->exec();
HDEBUG("exiting...");
}
示例12: main
int main(int argc, char *argv[])
{
// Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
QApplication app(argc, argv);
QQuickView viewer;
// The following are needed to make examples run without having to install the module
// in desktop environments.
#ifdef Q_OS_WIN
QString extraImportPath(QStringLiteral("%1/../../../../%2"));
#else
QString extraImportPath(QStringLiteral("%1/../../../%2"));
#endif
viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
QString::fromLatin1("qml")));
QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
QString appKey;
if (argc > 1) {
appKey = argv[1];
qDebug() << "App key for worldweatheronline.com:" << appKey;
} else {
qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data.";
}
viewer.setTitle(QStringLiteral("QML Weather"));
viewer.rootContext()->setContextProperty("weatherAppKey", appKey);
viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml"));
viewer.setResizeMode(QQuickView::SizeRootObjectToView);
viewer.show();
return app.exec();
}
示例13: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQuickView viewer;
PackageManager *pm = new PackageManager(&viewer);
QDeclarativeContext *context = viewer.rootContext();
context->setContextProperty("initialstate", "mainview");
context->setContextProperty("mainWindow", &viewer);
viewer.engine()->addImageProvider(QLatin1String("icons"), new IconProvider);
viewer.engine()->addImportPath("/usr/lib/qt5/imports");
qmlRegisterType<Package>("Package", 1,0, "Package");
qmlRegisterType<PackageGroup>("Package", 1,0, "PackageGroup");
qmlRegisterType<PackageMarkings>("Package", 1, 0, "PackageMarkings");
qmlRegisterType<Repository>("Repository", 1,0, "Repository");
viewer.setMainQmlFile(QLatin1String("qml/package-manager/main.qml"));
viewer.setOrientation(QQuickView::ScreenOrientationAuto);
viewer.showExpanded();
return app.exec();
}
示例14: main
int main(int argc, char *argv[])
{
// SailfishApp::main() will display "qml/template.qml", if you need more
// control over initialization, you can use:
//
// - SailfishApp::application(int, char *[]) to get the QGuiApplication *
// - SailfishApp::createView() to get a new QQuickView * instance
// - SailfishApp::pathTo(QString) to get a QUrl to a resource file
//
// To display the view, call "show()" (will show fullscreen on device).
QCoreApplication::setOrganizationName("org");
QCoreApplication::setOrganizationDomain("Sparkeyy");
QCoreApplication::setApplicationName("harbour-spritradar");
qmlRegisterType<Settings>("harbour.spritradar.Settings", 1,0, "Settings");
QGuiApplication* app = SailfishApp::application(argc, argv);
QQuickView* view = SailfishApp::createView();
QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));
view->rootContext()->setContextProperty("tankerkoenig_apikey", TANKERKOENIG_APIKEY); //Claim here: https://creativecommons.tankerkoenig.de/#register
// has to be set as additional qmake argument to the project configuration (armv7hl, i486 and debug/release for both), like this: "TANKERKOENIG_APIKEY=<your_apikey>"
view->setSource(SailfishApp::pathTo("qml/harbour-spritradar.qml"));
view->show();
return app->exec();
}
示例15: main
//=====================================================================================================================
int main(int argc, char* argv[])
//=====================================================================================================================
{
QGuiApplication app(argc, argv);
QQuickView viewer;
//QString extraImportPath(QStringLiteral("%1/../../../%2"));
//viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), QString::fromLatin1("qml")));
// set path to find the plugin
QString extraImportPath(QStringLiteral("%1/../pluginlib"));
QString path = extraImportPath.arg(QGuiApplication::applicationDirPath());
viewer.engine()->addImportPath(path);
// create list of my custom objects
Wrapper wrapper;
// and set the list as model
QQmlContext *ctxt = viewer.rootContext();
ctxt->setContextProperty("wrapper", &wrapper);
// set up connection
QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
viewer.setTitle(QStringLiteral("Custom Plugin Demo"));
viewer.setResizeMode(QQuickView::SizeRootObjectToView);
viewer.setSource(QUrl("qrc:/qml/view.qml"));
viewer.show();
return QGuiApplication::exec();
}