本文整理汇总了C++中QQuickView::engine方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickView::engine方法的具体用法?C++ QQuickView::engine怎么用?C++ QQuickView::engine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickView
的用法示例。
在下文中一共展示了QQuickView::engine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
qmlRegisterType<FileReader>("org.qtproject.testapi", 1, 0, "FileReader");
QQuickView view;
app.setOrganizationName("Acomb Methodist Church");
app.setOrganizationDomain("amc.com");
app.setApplicationName("Church Calendar");
#ifdef Q_OS_ANDROID
NotificationClient *notificationClient = new NotificationClient(&view);
view.engine()->rootContext()->setContextProperty(QLatin1String("notificationClient"),
notificationClient);
#endif
FileReader *fileReader = new FileReader(&view);
view.engine()->rootContext()->setContextProperty(QLatin1String("fileReader"),
fileReader);
view.engine()->addImportPath("/usr/share/qml/");
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl(QStringLiteral("qrc:/Views/Main.qml")));
view.show();
return app.exec();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: main
int main(int argc, char** argv)
{
QCoreApplication::setOrganizationName("com.ubuntu.developer.mzanetti.kodimote");
QCoreApplication::setApplicationName("kodimote");
QGuiApplication application(argc, argv);
// Load language file
QString language = QLocale::system().bcp47Name();
qDebug() << "got language:" << language;
QTranslator qtTranslator;
if(!qtTranslator.load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
qDebug() << "couldn't load qt_" + language;
}
application.installTranslator(&qtTranslator);
QTranslator translator;
if (!translator.load(":/kodimote_" + language + ".qm")) {
qDebug() << "Cannot load translation file" << "kodimote_" + language + ".pm";
}
application.installTranslator(&translator);
Kodi::instance()->setDataPath(QDir::homePath() + "/.cache/com.ubuntu.developer.mzanetti.kodimote/");
Kodi::instance()->eventClient()->setApplicationThumbnail("kodimote80.png");
QQuickView *view = new QQuickView();
Settings settings;
UbuntuHelper helper(view, &settings);
ProtocolManager protocols;
MprisController controller(&protocols, &helper);
Q_UNUSED(controller)
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->engine()->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory());
view->setTitle("Kodimote");
view->engine()->rootContext()->setContextProperty("kodi", Kodi::instance());
view->engine()->rootContext()->setContextProperty("settings", &settings);
view->engine()->rootContext()->setContextProperty("protocolManager", &protocols);
view->setSource(QUrl("qrc:///qml/main.qml"));
if(QGuiApplication::arguments().contains("--fullscreen")) {
view->showFullScreen();
} else {
// view->resize(QSize(720, 1280));
view->show();
}
return application.exec();
}
示例6: main
int main(int argc, char *argv[])
{
std::cout << "Have " << argc << " arguments:" << std::endl;
for (int i = 0; i < argc; ++i) {
std::cout << argv[i] << std::endl;
}
Client c;
if (argc > 1) {
c.doConnect();
}
QGuiApplication a(argc, argv);
QQuickView view;
QRCodeReader reader;
view.engine()->rootContext()->setContextProperty("qrCodeReader", &reader);
qmlRegisterType<QRCodeGenerator>("Tagger", 0, 1, "QRCodeGenerator");
view.engine()->addImageProvider(QStringLiteral("qrcode"), new QRCodeImageProvider);
view.engine()->addImageProvider(QStringLiteral("reader"), &reader);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl::fromLocalFile("qml/tagger.qml"));
view.show();
return a.exec();
}
示例7: main
int main(int argc, char* argv[])
{
QGuiApplication app(argc,argv);
qmlRegisterType<Connector>("Connector", 1, 0, "Connector");
app.setOrganizationName("QtProject");\
app.setOrganizationDomain("qt-project.org");\
app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
QQuickView view;\
if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
QSurfaceFormat f = view.format();\
f.setProfile(QSurfaceFormat::CoreProfile);\
f.setVersion(4, 4);\
view.setFormat(f);\
}\
view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));\
new QQmlFileSelector(view.engine(), &view);\
view.setSource(QUrl("qrc:///demos/tweetsearch/tweetsearch.qml")); \
view.setResizeMode(QQuickView::SizeRootObjectToView);\
if (QGuiApplication::platformName() == QLatin1String("qnx") || \
QGuiApplication::platformName() == QLatin1String("eglfs")) {\
view.showFullScreen();\
} else {\
view.show();\
}\
return app.exec();\
}
示例8: main
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
FileTest *fileTest = new FileTest();
fileTest->writeFilesToDisk();
fileTest->readFilesFromDisk();
NetworkTest *networkTest = new NetworkTest();
networkTest->TestHttp();
networkTest->TestHttps();
QQuickView view;
GpsClient *gpsClient = new GpsClient(&view);
view.engine()->rootContext()->setContextProperty(QLatin1String("gpsClient"),
gpsClient);
NotificationClient *notificationClient = new NotificationClient(&view);
view.engine()->rootContext()->setContextProperty(QLatin1String("notificationClient"),
notificationClient);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
view.show();
return app.exec();
}
示例9: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// If you want to use an engine, this shows how to get an UI Element!:
// QQmlApplicationEngine engine;
// engine.load(QUrl(QStringLiteral("qrc:/game.qml")));
// QObject root = engine.rootObjects().first();
// QObject element = root.findChild("element");
// element.setProperty("color","red");
//Creating Objects from Qml in C++ with QQuickView
//http://stackoverflow.com/questions/14092319/create-qml-element-in-c
QQuickView view;
//Background
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///game.qml"));
//Spaceshuttle
QQmlComponent component(view.engine(), QUrl("qrc:///shuttle.qml"));
QObject *shuttle = component.create();
//Components are only drawn if parent is somehow related to the root view
QQmlProperty::write(shuttle, "parent", QVariant::fromValue<QObject*>(view.rootObject()));
//some sample "Astroids" - ( wrong Image ;) )
QVector<QObject*> astroids(0);
for(int i = 0; i < 5; i++){
QQmlComponent fireballComponent(view.engine(), QUrl("qrc:///fireball.qml"));
astroids.append(fireballComponent.create());
QQmlProperty::write(astroids[i], "parent", QVariant::fromValue<QObject*>(view.rootObject()));
QQmlProperty::write(astroids[i], "x", i*50);
QQmlProperty::write(astroids[i], "y", i*50);
}
//QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
qDebug() << shuttle->property("id").toString();
Logger logger;
logger.setQObject(shuttle);
QObject::connect(shuttle, SIGNAL(xChanged()), &logger, SLOT(showCoordinates()));
view.show();
return app.exec();
}
示例10: main
int main(int argc, char** argv) {
// Initialize the Qt Application
QGuiApplication app(argc, argv);
// Register the HullRenderer QML Type
qmlRegisterType<HullRenderer>("com.nearce.HullRenderer", 1, 0, "HullRenderer");
// Establish the Qt Quick View
QQuickView view;
// Create the algorithm objecsts
GrahamScan grahamScan;
JarvisMarch jarvisMarch;
// Create the input genration objects
RandomPointInput randomPointInput(50, 1000);
CircularPointInput circularPointInput(50, 1000);
// Establish list of avalible alogrithms & inputs for the Hull Solver
QMap<QString, HullAlgorithm*> algorithms({
{grahamScan.name(), &grahamScan},
{jarvisMarch.name(), &jarvisMarch}
});
QMap<QString, DataInput*> inputs({
{randomPointInput.name(), &randomPointInput},
{circularPointInput.name(), &circularPointInput}
});
HullSolver solver(algorithms, inputs);
// Inject some C++ objects into the QML document structure
view.engine()->rootContext()->setContextProperty("random_input", &randomPointInput);
view.engine()->rootContext()->setContextProperty("circular_input", &circularPointInput);
view.engine()->rootContext()->setContextProperty("hull_solver", &solver);
// Establish a dynamicly resizing content resize policy & display the QML window
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///resources/main.qml"));
view.showMaximized();
// Create a signal slot connection between the HullRenderer QML object
// and the hull solver in C++ for convience
HullRenderer* renderer = view.rootObject()->findChild<HullRenderer*>("renderer");
QObject::connect(&solver, SIGNAL(solutionFound(const HullTimeline&)),
renderer, SLOT(setTimeline(const HullTimeline&)));
return app.exec();
}
示例11: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
#ifdef Q_OS_WIN
// Force usage of OpenGL ES through ANGLE on Windows
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
// Register the map view for QML
qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
qmlRegisterType<SetInitialMapArea>("Esri.Samples", 1, 0, "SetInitialMapAreaSample");
// Intialize application view
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
// Add the import Path
view.engine()->addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
// Set the source
view.setSource(QUrl("qrc:/Samples/Maps/SetInitialMapArea/SetInitialMapArea.qml"));
view.show();
return app.exec();
}
示例12: 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();
}
示例13: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
if (!QResource::registerResource("qmc_res3.rcc") ||
!QResource::registerResource("qmc_res5.rcc"))
{
qDebug() << "Could not register resources.";
return 1;
}
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
QQmlEngine *engine = view.engine();
QmcLoader loader(engine);
QQmlComponent *component = loader.loadComponent("qrc:/app.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();
}
}
示例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).
QGuiApplication *app = SailfishApp::application(argc, argv);
QTranslator translator;
translator.load(QLocale::system(), "ownNotes", "_", SailfishApp::pathTo("i18n").toLocalFile(), ".qm");
app->installTranslator(&translator);
QPython::registerQML();
qmlRegisterType<DocumentHandler>("net.khertan.documenthandler", 1, 0, "DocumentHandler");
QQuickView *view = SailfishApp::createView();
view->setSource(SailfishApp::pathTo("qml/ownNotes.qml"));
view->engine()->rootContext()->setContextProperty("VERSION", VERSION);
view->show();
return app->exec();
}
示例15: 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();
}