本文整理汇总了C++中QmlApplicationViewer::setSource方法的典型用法代码示例。如果您正苦于以下问题:C++ QmlApplicationViewer::setSource方法的具体用法?C++ QmlApplicationViewer::setSource怎么用?C++ QmlApplicationViewer::setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QmlApplicationViewer
的用法示例。
在下文中一共展示了QmlApplicationViewer::setSource方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//Main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
//system("sudo ifup wlan0");
Downloader d;
d.doDownload("http://www.vesta-tab.com/jo/showId.php");
Object data;
viewer.setCursor(Qt::BlankCursor);
viewer.rootContext()->setContextProperty("image", &data);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
//viewer.setMainQmlFile("qrc:/main.qml");
viewer.setSource(QUrl("qrc:/qml/BBB/main.qml"));
viewer.showFullScreen();
return app->exec();
}
示例2: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
#ifdef Q_OS_SYMBIAN
viewer.setMainQmlFile(QLatin1String("qrc:/qml/qvapp/qv.qml"));
viewer.setSource(QUrl(QLatin1String("qrc:/qml/qvapp/qv.qml")));
#else
viewer.setMainQmlFile(QLatin1String("qml/qvapp/qv.qml"));
#endif
#ifdef Q_OS_SYMBIAN
viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
viewer.showFullScreen();
#elif defined(Q_WS_MAEMO_5)
viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
viewer.showMaximized();
#elif defined(Q_OS_ANDROID)
viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
viewer.showFullScreen();
#else
Qt::WindowFlags flags = Qt::MSWindowsFixedSizeDialogHint
| Qt::CustomizeWindowHint
| Qt::WindowCloseButtonHint
| Qt::WindowMinimizeButtonHint;
viewer.setWindowFlags(flags);
viewer.setResizeMode(QDeclarativeView::SizeViewToRootObject);
viewer.show();
#endif
return app.exec();
}
示例3: QMainWindow
MuseBox::MuseBox(QWidget *parent) :
QMainWindow(parent)
{
//TODO add a splash screen here? would be totally fun!
qmlRegisterType<TrackArrangementBackground>("TrackArrangement",1,0,"TrackArrangementBackground");
qmlRegisterType<CursorRuler>("TrackArrangement",1,0,"CursorRuler");
qmlRegisterType<PatternModel>("DataModel",1,0,"PatternModel");
qmlRegisterType<NoteModel>("DataModel",1,0,"NoteModel");
qmlRegisterType<PatternDisplay>("TrackArrangement",1,0,"PatternDisplay");
qmlRegisterType<PatternNoteDisplay>("TrackArrangement",1,0,"PatternNoteDisplay");
QmlApplicationViewer *view = new QmlApplicationViewer();
view->rootContext()->setContextProperty("musebox", this);
view->rootContext()->setContextProperty("trackModel", &this->trackModel);
view->setSource(QUrl::fromLocalFile("qml/MuseBox/main.qml"));
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
QGLFormat format = QGLFormat::defaultFormat();
format.setSampleBuffers(false);
QGLWidget *glWidget = new QGLWidget(format);
glWidget->setAutoFillBackground(false);
view->setViewport(glWidget);
setCentralWidget(view);
Hardware::Init();
view->rootContext()->setContextProperty("transposeMachine", Hardware::TransposeMachine);
Hardware::StartAudio();
}
示例4: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// Localization: Loads the application translation depending on the mobile language.
QTranslator translator;
QString locale = QLocale::system().name();
translator.load("qml_" + locale, ":/qml/i18n/");
app.installTranslator(&translator);
UserAgentProvider p;
QString userAgent = p.getUserAgent();
NetworkAccessManagerFactory factory(userAgent);
QmlApplicationViewer viewer;
viewer.engine()->setNetworkAccessManagerFactory(&factory);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setSource(QUrl("qrc:///qml/main.qml"));
// Performance operations
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
viewer.window()->showFullScreen();
viewer.engine()->networkAccessManager()->cache()->clear();
return app.exec();
}
示例5: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> App(createApplication(argc, argv));
QTranslator Translator;
if (!Translator.load("tr_"+QLocale::system().name(), ":/i18n"))
Translator.load("tr_en", ":/i18n");
App->installTranslator(&Translator);
ConTranslator ConsoleMsgs;
ConsoleMsgs.load("conmsgs", ":/i18n");
App->installTranslator(&ConsoleMsgs);
IconProvider::SetToCurrentSystemTheme();
Context Ctx(argc, argv);
ScopedIntercomHandler Intercom;
if (Ctx.IfExit())
return Intercom->GetExitCode();
{
ModesModel ModesList(Ctx.CheckMode(), Ctx.CheckMode()==RunModes::PRINT);
UsersModel UsersList(Ctx.GetTargetUser(), Ctx.CheckMode()==RunModes::PRINT);
DesktopModel AppList;
PswTools PassCheck;
QmlApplicationViewer Viewer;
qmlRegisterUncreatableType<RunModes>("com.lcferrum.hmtsu", 1, 0, "RunModes", "Exports RunModes enum to QML");
Viewer.engine()->addImageProvider("icon", new IconProvider()); //It is QDeclarativeEngine's responsibility to destroy added image providers
Viewer.rootContext()->setContextProperty("objModesList", &ModesList);
Viewer.rootContext()->setContextProperty("objUsersList", &UsersList);
Viewer.rootContext()->setContextProperty("objAppList", &AppList);
Viewer.rootContext()->setContextProperty("objContext", &Ctx);
Viewer.rootContext()->setContextProperty("objIntercom", &Intercom);
Viewer.rootContext()->setContextProperty("objPassCheck", &PassCheck);
Viewer.rootContext()->setContextProperty("HMTSU_VERSION_STRING", HMTSU_VERSION_STRING IF_DEBUG(" (DEBUG)"));
Viewer.rootContext()->setContextProperty("HMTSU_COPYRIGHT_STRING", HMTSU_COPYRIGHT_STRING);
Viewer.rootContext()->setContextProperty("CANCELED_EXIT_CODE", CANCELED_EXIT_CODE);
Viewer.rootContext()->setContextProperty("DENIED_EXIT_CODE", DENIED_EXIT_CODE);
Viewer.rootContext()->setContextProperty("NORMAL_EXIT_CODE", NORMAL_EXIT_CODE);
Viewer.rootContext()->setContextProperty("MAX_PSW_ATTEMPTS", MAX_PSW_ATTEMPTS);
Viewer.setSource(QUrl("qrc:/main.qml"));
Viewer.showExpanded();
App->exec();
}
Ctx.Run();
return Intercom->GetExitCode();
}
示例6: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationName("BBSimpleCalc ");
app.setApplicationVersion("1.0rc LGPL 3.0 lic.");
app.setOrganizationName("Silesian University of Technology Students");
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.setResizeMode(QmlApplicationViewer::SizeRootObjectToView);
viewer.setSource(QUrl("qrc:/qml/main.qml"));
viewer.setWindowState(Qt::WindowFullScreen);
viewer.showExpanded();
return app.exec();
}
示例7: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
viewer.addImportPath(QLatin1String("imports"));
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
#ifdef Q_OS_BLACKBERRY
Scoreloop scoreloop;
viewer.rootContext()->setContextProperty("scoreloop", &scoreloop);
#endif
viewer.setSource(QUrl("qrc:/qml/game/main.qml"));
viewer.showExpanded();
return app->exec();
}
示例8: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
viewer.setAttribute(Qt::WA_LockPortraitOrientation);
Helper helper;
viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
viewer.rootContext()->setContextProperty("Helper", &helper);
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
viewer.setSource(QUrl("qrc:/qml/main.qml"));
viewer.showFullScreen();
return app->exec();
}
示例9: main
Q_DECL_EXPORT int main(int argc, char *argv[]) {
QApplication app(argc, argv);
// register types
qmlRegisterType<DatabaseManager>("tessera", 1, 0, "Database" );
qmlRegisterType<ClipboardAdapter>("tessera", 1, 0, "Clipboard" );
qmlRegisterUncreatableType<SqlQueryModel>("tessera", 1, 0, "SqlQuery", "");
// do my cool qt4 stuff
#if QT_VERSION < 0x050000
QmlApplicationViewer viewer;
viewer.setSource( QUrl(QLatin1String("qrc:/qml/Symbian.qml")) );
viewer.showFullScreen();
#else
// Qt5 cool stuff
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///qml/Desktop.qml")));
#endif
return app.exec();
}
示例10: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
qmlRegisterType<Dict>("Vortaro", 1, 0, "Dict");
qmlRegisterType<Word>("Vortaro", 1, 0, "Word");
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
QDeclarativeEngine *engine = viewer.engine();
QDeclarativeContext *rootContext = engine->rootContext();
// engine->addImportPath(QString("/opt/nokia/qtsdk/Simulator/Qt/gcc/imports"));
Session session;
session.load();
rootContext->setContextObject(&session);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
viewer.setSource(QUrl("qrc:///qml/main.qml"));
// viewer.setMainQmlFile(QString("qml/main.qml"));
viewer.showExpanded();
return app->exec();
}
示例11: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
int currentExitCode = 0;
QScopedPointer<QSymbianApplication> app(new QSymbianApplication(argc, argv));
// Set App Info:
app->setApplicationName("Battery Status");
app->setOrganizationName("Motaz Alnuweiri");
app->setApplicationVersion(APP_Version);
// QT_DEBUG or QT_NO_DEBUG
// #ifdef QT_DEBUG
// // Install Debug Msgs Handler:
// ClearDebugFile();
// qInstallMsgHandler(DebugFileHandler);
// #endif
// Install EventFilter in QApplication:
//app->installEventFilter(new myEventFilter);
// Set App Splash Screen:
QSplashScreen *splash = new QSplashScreen(QPixmap(":qml/Images/JPG/Splash_Screen.jpg"),
Qt::WindowStaysOnTopHint);
splash->show();
// Check System Language & Load App Translator:
QString systemLang = QLocale::system().name();
QTranslator appTranslator;
systemLang.truncate(2); //truncate(2) to ignore the country code
if (QFile::exists("Languages/batterystatus_" + systemLang + ".qm")) {
appTranslator.load("batterystatus_" + systemLang, "Languages");
} else {
appTranslator.load("batterystatus_en", "Languages");
}
// Install QTranslator to QApplication:
app->installTranslator(&appTranslator);
// Hide The App If Deactive:
if (!app->foreground())
QSymbianHelper::hideInBackground();
// Register QSettings:
QAppSettings appSettings;
// Register QmlApplicationViewer:
QmlApplicationViewer *viewer = new QmlApplicationViewer();
//viewer.setResizeMode(QmlApplicationViewer::SizeRootObjectToView);
//viewer.setAutoFillBackground(false);
//viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
// Register App HSWidget:
QBatteryHSWidget *batteryHSWidget = new QBatteryHSWidget();
batteryHSWidget->setBackgroundOpacity(appSettings.getWidgetOpacity());
// Register QDeviceName:
QDeviceName deviceName;
// Register Class to QML:
qmlRegisterType<QPSMode>("PSMode", 1, 0, "PSMode");
qmlRegisterType<QGlobalNote>("GlobalNote", 1, 0, "GlobalNote");
qmlRegisterType<QCBatteryInfo>("CBatteryInfo", 1, 0, "CBatteryInfo");
qmlRegisterType<CommonType>("CommonType", 1, 0, "CommonType");
// Set Propertys to QML:
viewer->rootContext()->setContextProperty("APPName", QObject::tr("Battery Status"));
viewer->rootContext()->setContextProperty("APPVersion", app->applicationVersion());
viewer->rootContext()->setContextProperty("AppPath", app->applicationDirPath());
viewer->rootContext()->setContextProperty("SymbianHelper", new QSymbianHelper);
viewer->rootContext()->setContextProperty("AppSettings", &appSettings);
viewer->rootContext()->setContextProperty("HSWidget", batteryHSWidget);
viewer->rootContext()->setContextProperty("DeviceName", &deviceName);
viewer->rootContext()->setContextProperty("QApp", app->instance());
viewer->setSource(QUrl(QLatin1String("qrc:qml/main.qml")));
//viewer.setSource(QUrl::fromLocalFile("qrc:qml/main.qml"));
// Lock screen orientation in portrait only
//viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
//viewer.setGeometry(app->desktop()->screenGeometry());
viewer->showFullScreen();
// Stop Splash Screen & Delete It:
splash->finish(viewer);
splash->deleteLater();
//viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
// Enter App Event Loop:
currentExitCode = app->exec();
// Cleun Pointers:
delete viewer;
delete batteryHSWidget;
// Check If App Is Restarting:
//.........这里部分代码省略.........
示例12: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
bool use_qml;
#ifdef USE_QML
use_qml = true;
#else
use_qml = false;
#endif
QStringList options = app.arguments();
if (options.contains("--use-qml"))
use_qml = true;
if (options.contains("--dont-use-qml"))
use_qml = false;
if (use_qml) {
qRegisterMetaType<DNSSECTest>("DNSSECTest");
qmlRegisterType<DNSSECTest, 1>("DNSSECTools", 1, 0, "DNSSECTest");
qmlRegisterType<TestManager, 1>("DNSSECTools", 1, 0, "TestManager");
QmlApplicationViewer viewer;
QDeclarativeContext *context;
viewer.addImportPath(":/qml");
viewer.setWindowIcon(QIcon(":/images/dnssec-check-64x64.png"));
viewer.setWindowTitle("DNSSEC-Check");
TestManager manager;
context = viewer.rootContext();
context->setContextProperty("testManager", &manager);
#ifdef IS_MEEGO
viewer.setSource(QUrl("qrc:/qml/MeegoDnssecCheck.qml"));
#else
viewer.setSource(QUrl("qrc:/qml/DnssecCheck.qml"));
#endif
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
#ifdef IS_MEEGO
viewer.showFullScreen();
#else
viewer.show();
#endif
return app.exec();
} else { // don't use QML
MainWindow mainWindow;
mainWindow.setOrientation(MainWindow::Auto);
#ifdef Q_OS_SYMBIAN
mainWindow.showFullScreen();
#elif defined(Q_WS_MAEMO_5)
mainWindow.showMaximized();
#else
mainWindow.show();
#endif
return app.exec();
}
}
示例13: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
#ifdef Q_OS_SYMBIAN
QApplication::setAttribute((Qt::ApplicationAttribute)11); //Qt::AA_CaptureMultimediaKeys
#endif
QApplication app(argc, argv);
app.setApplicationName("QVideo");
app.setOrganizationName("QShen");
app.setApplicationVersion(VER);
QString locale = QLocale::system().name();
QTranslator translator;
if(!translator.load(QString("QVideo_") + locale,":/i18n")){
qDebug()<<"translator load erro";
}
app.installTranslator(&translator);
Utility utility;
Settings settings;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QmlApplicationViewer viewer;
//viewer.setAttribute(Qt::WA_OpaquePaintEvent);
//viewer.setAttribute(Qt::WA_NoSystemBackground);
//viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
//viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
viewer.rootContext()->setContextProperty("utility", &utility);
viewer.rootContext()->setContextProperty("settings", &settings);
viewer.rootContext()->setContextProperty("appVersion", app.applicationVersion());
#ifdef Q_OS_SYMBIAN
QSplashScreen *splash = new QSplashScreen(QPixmap(":/qml/pic/splash_symbian.png"));
splash->show();
splash->raise();
viewer.setSource(QUrl("qrc:/qml/Symbian/main.qml"));
#elif defined(Q_OS_HARMATTAN)
//QApplication::setGraphicsSystem("native");
viewer.setSource(QUrl("qrc:/qml/Meego/main.qml"));
#elif defined(Q_WS_SIMULATOR)
viewer.setSource(QUrl("qrc:/qml/Symbian/main.qml"));
#endif
viewer.showExpanded();
#else
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("utility",&utility);
#ifdef Q_OS_WIN32
engine.load(QUrl(QStringLiteral("qrc:/qml/Win32/main.qml")));
#endif
#endif
#ifdef Q_OS_SYMBIAN
splash->finish(&viewer);
splash->deleteLater();
#endif
return app.exec();
}