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); viewer.setTitle(QStringLiteral("QML Chart")); viewer.setSource(QUrl("qrc:/qml/qmlchart/main.qml")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.show(); return app.exec(); }
int main(int argc, char *argv[]) { QGuiApplication 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"))); viewer.setSource(QUrl("qrc:/main.qml")); viewer.setTitle(QStringLiteral("Interaction")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.setColor("#fafafa"); viewer.show(); return app.exec(); }
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(); }
int main(int argc, char *argv[]) { //! [0] // Uncomment to turn on all the logging categories of Canvas3D // QString loggingFilter = QString("qt.canvas3d.info.debug=true\n"); // loggingFilter += QStringLiteral("qt.canvas3d.rendering.debug=true\n") // + QStringLiteral("qt.canvas3d.rendering.warning=true\n") // + QStringLiteral("qt.canvas3d.glerrors.debug=true"); // QLoggingCategory::setFilterRules(loggingFilter); //! [0] QGuiApplication 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"))); viewer.setSource(QUrl("qrc:/main.qml")); viewer.setTitle(QStringLiteral("Textured and Lit Cube")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.setColor("#fafafa"); viewer.show(); return app.exec(); }
//===================================================================================================================== 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(); }