当前位置: 首页>>代码示例>>C++>>正文


C++ QmlApplicationViewer::width方法代码示例

本文整理汇总了C++中QmlApplicationViewer::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QmlApplicationViewer::width方法的具体用法?C++ QmlApplicationViewer::width怎么用?C++ QmlApplicationViewer::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QmlApplicationViewer的用法示例。


在下文中一共展示了QmlApplicationViewer::width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    //qDebug()<<QString::fromUtf8("主线程地址是:")<<QThread::currentThread();
#if defined(Q_OS_SYMBIAN)||defined(Q_WS_SIMULATOR)
    QPixmap pixmap(":/Image/Symbian.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    splash->show();
    splash->raise();
#endif

#ifndef QT_NO_DEBUG
    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::HttpProxy);
    proxy.setHostName("localhost");
    proxy.setPort(8888);
    QNetworkProxy::setApplicationProxy(proxy);
#endif
    //int width=QApplication::desktop()->width();
    //int height=QApplication::desktop()->height();
    app->setApplicationName (QString::fromUtf8("IT之家"));
    app->setOrganizationName ("Stars");
    app->setApplicationVersion ("1.2.2");
    Settings *setting=new Settings;
    Utility *unility=new Utility;
    Cache *cacheContent=new Cache(setting);
    //qmlRegisterType<MyXmlListModel>("myXmlListModel",1,0,"MyXmlListModel");
    //qmlRegisterType<MyXmlRole>("myXmlListModel", 1, 0, "MyXmlRole");

    QmlApplicationViewer viewer;
    
    MyNetworkAccessManagerFactory *network = new MyNetworkAccessManagerFactory();
    viewer.engine()->setNetworkAccessManagerFactory(network);
    
    viewer.rootContext ()->setContextProperty ("cacheContent",cacheContent);
    viewer.rootContext()->setContextProperty("settings",setting);
    viewer.rootContext()->setContextProperty("utility",unility);
    
    QWebSettings::globalSettings ()->setAttribute (QWebSettings::LocalContentCanAccessRemoteUrls,true);
    QWebSettings::globalSettings ()->setAttribute (QWebSettings::SpatialNavigationEnabled,true);
    QWebSettings::globalSettings ()->setAttribute (QWebSettings::SpatialNavigationEnabled, true);
#if defined(Q_OS_SYMBIAN)||defined(Q_WS_SIMULATOR)
#if defined(Q_OS_S60V5)//判断qt的版本
    qWarning("build symbian s60v5");
    viewer.setMainQmlFile(QLatin1String("qml/symbian-v5/main.qml"));
    if(setting->getValue("night_mode",false).toBool())
        unility->setCss("./qml/symbian-v5/theme_black.css",viewer.width()-20);//设置默认的css
    else
        unility->setCss("./qml/symbian-v5/theme_white.css",viewer.width()-20);
#elif defined(Q_OS_S60V3)
    qWarning("build symbian s60v3");
    viewer.setMainQmlFile(QLatin1String("qml/symbian-v3/main.qml"));
    if(setting->getValue("night_mode",false).toBool())
        unility->setCss("./qml/symbian-v3/theme_black.css",viewer.width()-20);//设置默认的css
    else
        unility->setCss("./qml/symbian-v3/theme_white.css",viewer.width()-20);
#else
    qWarning("build symbian anna or simulator");
    viewer.setMainQmlFile(QLatin1String("qml/symbian-anna/main.qml"));
    if(setting->getValue("night_mode",false).toBool())
        unility->setCss("./qml/symbian-anna/theme_black.css",viewer.width()-20);//设置默认的css
    else
        unility->setCss("./qml/symbian-anna/theme_white.css",viewer.width()-20);
#endif
    viewer.showExpanded();
    splash->finish(&viewer);
    splash->deleteLater();
#elif defined(Q_OS_HARMATTAN)
    qWarning("build meego");
    viewer.setMainQmlFile(QLatin1String("qml/meego/main.qml"));
    if(setting->getValue("night_mode",false).toBool())
        unility->setCss("/opt/ithome/qml/meego/theme_black.css",460);//设置默认的css
    else
        unility->setCss("/opt/ithome/qml/meego/theme_white.css",460);
    viewer.showExpanded();
#endif
    return app->exec();
}
开发者ID:ydxt25,项目名称:ithome-1,代码行数:78,代码来源:main.cpp


注:本文中的QmlApplicationViewer::width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。