本文整理汇总了C++中QQmlApplicationEngine::rootObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlApplicationEngine::rootObjects方法的具体用法?C++ QQmlApplicationEngine::rootObjects怎么用?C++ QQmlApplicationEngine::rootObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlApplicationEngine
的用法示例。
在下文中一共展示了QQmlApplicationEngine::rootObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
Q_INIT_RESOURCE(resources);
QGuiApplication app(argc, argv);
app.setApplicationName("osmand-qt");
app.setApplicationVersion("0.1");
__CoreResourcesEmbeddedBundle__FakeReferences();
shared_ptr<const CoreResourcesEmbeddedBundle> bundle =
CoreResourcesEmbeddedBundle::loadFromCurrentExecutable();
InitializeCore(bundle);
qmlRegisterType<MapCanvas>("OsmAndQt", 1, 0, "MapCanvas");
qmlRegisterUncreatableType<Resources>("OsmAndQt", 1, 0, "Resources", "");
qmlRegisterUncreatableType<ResourceModel>("OsmAndQt", 1, 0, "ResourceModel", "");
Resources resources;
resources.downloadIfNecessary(QList<QString>()
<< "world_basemap.map.obf"
<< "austria_europe.map.obf"
);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("contextResources", &resources);
engine.load(QUrl("qrc:/src/Main.qml"));
qobject_cast<QQuickWindow *>(engine.rootObjects().value(0))->show();
return app.exec();
}
示例2: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model;
model.appendRow(new QStandardItem("Norway"));
model.appendRow(new QStandardItem("Netherlands"));
model.appendRow(new QStandardItem("New Zealand"));
model.appendRow(new QStandardItem("Namibia"));
model.appendRow(new QStandardItem("Nicaragua"));
model.appendRow(new QStandardItem("North Korea"));
model.appendRow(new QStandardItem("Northern Cyprus "));
model.appendRow(new QStandardItem("Sweden"));
model.appendRow(new QStandardItem("Denmark"));
QStringList strings;
strings << "Norway" << "Sweden" << "Denmark";
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("standardmodel", &model);
engine.rootContext()->setContextProperty("stringmodel", strings);
engine.load(QUrl("main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
if ( !window ) {
qWarning("Error: Your root item has to be a Window.");
return -1;
}
window->show();
return app.exec();
}
示例3: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
//test_handcontrol mytest_handcontrol;
handcontrol myhandcontrol;
//char video_name[] = "test.mp4";
//mytest_handcontrol.openFile(video_name);
//qmlRegisterType<handcontrol>("handcontrol", 1, 0, "Handcontrol");
engine.load(QUrl(QStringLiteral("qrc:/main_handcontrol.qml")));
QObject *root = engine.rootObjects()[0];
QObject *cameraComponent = root->findChild<QObject*>("camera");
QCamera *camera = qvariant_cast<QCamera*>(cameraComponent->property("mediaObject"));
myhandcontrol.setCamera(camera);
//myhandcontrol.setQMLCamera(qmlCamera);
//root->setProperty("frame_count", mytest_handcontrol.getNrOfFrames());
QObject::connect(root, SIGNAL(handcontrol_enable(int)),&myhandcontrol, SLOT(enable(int)));
QObject::connect(&myhandcontrol, SIGNAL(debugMessage(QVariant)),root, SLOT(print_debugMessage(QVariant)));
QObject::connect(&myhandcontrol, SIGNAL(errorMessage(QVariant)),root, SLOT(print_errorMessage(QVariant)));
QObject::connect(&myhandcontrol, SIGNAL(change_page(QVariant)),root, SLOT(count_page(QVariant)));
//engine.addImageProvider(QLatin1String("test_handcontrol"), &mytest_handcontrol);
qDebug()<<"From main thread: "<<QThread::currentThreadId();
return app.exec();
}
示例4: setCurrentCatalog
void MasterCatalogModel::setCurrentCatalog(CatalogModel *cat)
{
if (!_rootObject){
QQmlApplicationEngine *engine = dynamic_cast<QQmlApplicationEngine *>(_qmlcontext->engine());
if ( engine){
QObject *top = engine->rootObjects().value(0);
QObject *topLevel = top->findChild<QObject *>("mainwindow__mainui");
if ( topLevel){
_rootObject = topLevel;
}
}
}
if ( cat->url() == Catalog::DEFAULT_WORKSPACE){
Resource res = Ilwis::Resource(context()->workingCatalog()->resource().url().toString(), itCATALOG);
_lastCatalog = _currentCatalog;
_currentCatalog = new CatalogModel(res, CatalogModel::getCatalogType(res), this);
} else{
_lastCatalog = _currentCatalog;
_currentCatalog = cat;
if ( _rootObject){
QObject *obj = _rootObject->findChild<QObject *>("main_ui_catalogform");
if ( obj && cat->url().indexOf("file://") == 0){
obj->setProperty("currentFolder", cat->url());
}
}
}
ICatalog catalog(cat->url());
if ( catalog.isValid()){
context()->setWorkingCatalog(catalog);
mastercatalog()->addContainer(cat->url());
}
}
示例5: main
int main(int argc, char *argv[])
{
#ifdef Q_OS_IOS
QGuiApplication app(argc, argv);
#else
QApplication app(argc,argv);
#endif
QQmlApplicationEngine engine;
// Quick iOS Initialization
engine.addImportPath("qrc:///");
QuickIOS::registerTypes(); // It must be called before loaded any scene
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QQuickWindow *window = qobject_cast<QQuickWindow *>(engine.rootObjects().first());
/// Setup the QQuickWindow instance to fit the iOS environment
QuickIOS::setupWindow(window);
QuickIOS::setStatusBarStyle(QuickIOS::StatusBarStyleDefault);
QISystemMessenger::instance()->sendMessage("activityIndicatorStart",QVariantMap());
printSystemInformation();
return app.exec();
}
示例6: run_ui
void run_ui()
{
qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
QQmlApplicationEngine engine;
engine.addImportPath("qrc://imports");
DiveListModel diveListModel;
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(0);
sortModel->setSourceModel(&diveListModel);
sortModel->setDynamicSortFilter(true);
sortModel->setSortRole(DiveListModel::DiveDateRole);
sortModel->sort(0, Qt::DescendingOrder);
QQmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty("diveModel", sortModel);
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
qqWindowObject = engine.rootObjects().value(0);
if (!qqWindowObject) {
fprintf(stderr, "can't create window object\n");
exit(1);
}
QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
qml_window->setIcon(QIcon(":/subsurface-mobile-icon"));
qqWindowObject->setProperty("messageText", QVariant("Subsurface mobile startup"));
#if !defined(Q_OS_ANDROID)
qml_window->setHeight(1200);
qml_window->setWidth(800);
#endif
qml_window->show();
qApp->exec();
}
示例7: main
int main(int argc, char *argv[])
{
QGuiApplication application(argc, argv);
QVariantMap parameters;
QStringList args(QCoreApplication::arguments());
if (parseArgs(args, parameters))
return 0;
if (!args.contains(QStringLiteral("osm.useragent")))
parameters[QStringLiteral("osm.useragent")] = QStringLiteral("QtLocation Mapviewer example");
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral(":/imports"));
engine.load(QUrl(QStringLiteral("qrc:///mapviewer.qml")));
QObject::connect(&engine, SIGNAL(quit()), qApp, SLOT(quit()));
QObject *item = engine.rootObjects().first();
Q_ASSERT(item);
QMetaObject::invokeMethod(item, "initializeProviders",
Q_ARG(QVariant, QVariant::fromValue(parameters)));
return application.exec();
}
示例8: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("ScreenW",1920);//1920x1080
engine.rootContext()->setContextProperty("ScreenH",1080);
DiceResultModel* model = new DiceResultModel();
engine.rootContext()->setContextProperty("_diceModel",model);
/* QTextDocument text(NULL);
CppHighLighter cppHighLighter(&text);
engine.rootContext()->setContextProperty("_hightedDoc",&text);*/
//engine.rootContext()->setContextProperty("CppHighLightedDocument",720);
QmlControler ctr;
ctr.setResultModel(model);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QList<QObject*> roots = engine.rootObjects();
QObject* root = roots.at(0);
QObject::connect(root,SIGNAL(rollDiceCmd(QString)),&ctr,SLOT(rollDice(QString)));
ctr.setEngine(&engine);
ctr.setVisible(true);
return app.exec();
}
示例9: main
int main(int argc, char **argv)
{
Application app(argc, argv);
app.setOrganizationName("liri-browser");
app.setOrganizationDomain("liri-browser.github.io");
app.setApplicationName("liri-browser");
// Load Translations
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
QTranslator translator;
translator.load("translations/" + QLocale::system().name());
app.installTranslator(&translator);
// Initialize QtWebEngine
QtWebEngine::initialize();
QQmlApplicationEngine appEngine;
//appEngine.rootContext()->setContextProperty("utils", &utils);
appEngine.load(QUrl("qrc:/qml/DesktopApplication.qml"));
QMetaObject::invokeMethod(appEngine.rootObjects().first(), "load");
return app.exec();
}
示例10: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// set path where recorded data will be stored
qDebug() << "catalogPath: "<<Sbs2Common::setDefaultCatalogPath();
// set path where application data is stored
qDebug() << "rootAppPath: "<<Sbs2Common::setDefaultRootAppPath();
MyCallback* myCallback = new MyCallback();
//Sbs2FakeDataReader* sbs2DataReader = Sbs2FakeDataReader::New(myCallback,0);
Sbs2EmotivDataReader* sbs2DataReader = Sbs2EmotivDataReader::New(myCallback,0);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
// Get access to the rectangle
QObject *rootObject = engine.rootObjects().first();
QObject *rect = rootObject->findChild<QObject*>("rect");
//QObject *rect = engine.findChild<QObject*>();
if (rect) {
QObject::connect(myCallback,SIGNAL(timeTick8()),rect,SLOT(timeTick()));
QObject::connect(myCallback,SIGNAL(valueSignal(QVariant)),rect,SLOT(channelValue(QVariant)));
QObject::connect(&app, SIGNAL(aboutToQuit()), sbs2DataReader, SLOT(aboutToQuit()));
QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
qDebug() << "succes";
} else {
qDebug() << "fail";
}
return app.exec();
}
示例11: main
int main(int argc, char *argv[])
{
QGuiApplication::setApplicationName("BaasExample");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
//#if defined(Q_OS_ANDROID)
//TODO : fix registering via registerFilterTypes() Q_COREAPP_STARTUP_FUNCTION (not called with Android?)
//registerFilterTypes();
//#endif
qmlRegisterSingletonType( QUrl("qrc:/qml/singleton/Assets.qml"),"BaaS.Example.Assets", 1, 0,"Assets");
#ifdef APPVERSION
engine.rootContext()->setContextProperty( "appVersion", QString( APPVERSION ));
#endif
engine.addImportPath("qrc:///");
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
示例12: CreateMainWindow
int Wimp::CreateMainWindow()
{
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
topLevel = engine.rootObjects().value(0);
window = qobject_cast<QQuickWindow *>(topLevel);
SetTitle("Hello QT");
return this->exec();
}
示例13: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtWebEngine::initialize();
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (argc > 1)
{
QMetaObject::invokeMethod(engine.rootObjects().first(), "load", Q_ARG(QVariant, argv[1]));
}
else
{
QMetaObject::invokeMethod(engine.rootObjects().first(), "load", Q_ARG(QVariant, "http://www.google.com"));
}
return app.exec();
}
示例14: main
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QThread *cameraThread = new QThread(&app);
cameraThread->start();
CameraCapturer *capturer = new CameraCapturer();
CameraImageProvider *imageProvider = new CameraImageProvider();
capturer->moveToThread(cameraThread);
imageProvider->moveToThread(cameraThread);
QObject::connect(capturer, static_cast<void (CameraCapturer::*)(QImage)>(
&CameraCapturer::frame),
imageProvider, &CameraImageProvider::setImage);
engine.addImageProvider("camera", imageProvider);
QThread *imageProcessingThread = new QThread(&app);
imageProcessingThread->start();
SquintDetector *squintDetector = new SquintDetector();
squintDetector->moveToThread(imageProcessingThread);
qRegisterMetaType<cv::Mat>("cv::Mat");
QObject::connect(capturer, static_cast<void (CameraCapturer::*)(cv::Mat)>(
&CameraCapturer::frame),
squintDetector, &SquintDetector::updateFrame);
capturer->startCapture(16);
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
QObject *mainWindow = engine.rootObjects()[0];
QObject *arkanoid = mainWindow->children()[0];
ArkanoidManager *aManager = new ArkanoidManager(arkanoid);
QObject::connect(squintDetector, &SquintDetector::leftEye,
aManager, &ArkanoidManager::leftEye);
QObject::connect(squintDetector, &SquintDetector::rightEye,
aManager, &ArkanoidManager::rightEye);
QObject::connect(squintDetector, &SquintDetector::noEye,
aManager, &ArkanoidManager::noEye);
QObject::connect(squintDetector, &SquintDetector::bothEyes,
aManager, &ArkanoidManager::bothEyes);
QObject::connect(&app, &QGuiApplication::aboutToQuit, [=]() {
// capturer->stopCapture();
// delete capturer;
// delete imageProvider;
// cameraThread->exit();
// delete squintDetector;
// imageProcessingThread->exit();
qDebug() << "bye";
});
return app.exec();
}
示例15: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(qApp->applicationDirPath() + QStringLiteral("/data/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}