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


C++ QQmlApplicationEngine::setNetworkAccessManagerFactory方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QQmlApplicationEngine engine;

    //! [0]
    engine.setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);
    //! [0]

    engine.load(QUrl(QStringLiteral("qrc:/qml/NetworkImageCache/main.qml")));

    return app.exec();
}
开发者ID:GDPURJYFS,项目名称:A-week-to-develop-android-app-plan,代码行数:14,代码来源:main.cpp

示例2: main

Q_DECL_EXPORT int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    app.setOrganizationName("cuteTube2");
    app.setApplicationName("cuteTube2");

    Settings settings;
    Clipboard clipboard;
    Dailymotion dailymotion;
    DBusService dbus;
    NetworkAccessManagerFactory factory;
    Resources resources;
    ResourcesPlugins plugins;
    Transfers transfers;
    Utils utils;
    VideoLauncher launcher;
    Vimeo vimeo;
    YouTube youtube;
        
    initDatabase();
    registerTypes();
    plugins.load();
    settings.setNetworkProxy();
    
    QQmlApplicationEngine engine;
    QQmlContext *context = engine.rootContext();
    
    context->setContextProperty("Clipboard", &clipboard);
    context->setContextProperty("CookieJar", factory.cookieJar());
    context->setContextProperty("Dailymotion", &dailymotion);
    context->setContextProperty("DBus", &dbus);
    context->setContextProperty("Plugins", &plugins);
    context->setContextProperty("Resources", &resources);
    context->setContextProperty("Settings", &settings);
    context->setContextProperty("Transfers", &transfers);
    context->setContextProperty("Utils", &utils);
    context->setContextProperty("VideoLauncher", &launcher);
    context->setContextProperty("Vimeo", &vimeo);
    context->setContextProperty("YouTube", &youtube);
    context->setContextProperty("AUDIO_CONVERTOR_ENABLED", (QFile::exists("/usr/bin/ffmpeg"))
                                                           || (QFile::exists("/usr/bin/avconv")));
    context->setContextProperty("MAX_RESULTS", MAX_RESULTS);
    context->setContextProperty("VERSION_NUMBER", VERSION_NUMBER);

    engine.setNetworkAccessManagerFactory(&factory);
    engine.load("/opt/cutetube2/qml/main.qml");
    
    return app.exec();
}
开发者ID:freemangordon,项目名称:cutetube2,代码行数:48,代码来源:main.cpp

示例3: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    
    app.setApplicationName ("QQStars");
    app.setApplicationVersion ("1.0.0");
    app.setOrganizationName ("雨后星辰");
    app.setApplicationDisplayName ("星辰QQ");
    
    QTranslator *translator = new QTranslator;
    translator->load (":/qt_zh_CN.qm");
    QApplication::installTranslator (translator);
    
    QQmlApplicationEngine *engine = new QQmlApplicationEngine;
    engine->setNetworkAccessManagerFactory (new MyNetworkAccessManagerFactory());//给qml设置网络请求所用的类
    
    qmlRegisterType<TextEditPlayGif>("MyTextEditPlugin", 1, 0, "TextEditPlayGif");
    qmlRegisterType<MyWindow>("mywindow", 1,0, "MyQuickWindow");
    qmlRegisterType<SystemTrayIcon>("mywindow", 1,0, "MySystemTrayIcon");
    qmlRegisterType<MyMenu>("mywindow", 1,0, "MyMenu");
    qmlRegisterType<MenuSeparator>("mywindow", 1,0, "MenuSeparator");
    qmlRegisterType<MyMenuItem>("mywindow", 1,0, "MyMenuItem");
    qmlRegisterType<MyShortcut>("utility", 1,0, "MyShortcut");
    qmlRegisterType<DownloadImage>("utility", 1, 0, "DownloadImage");
    qmlRegisterType<QQCommand>("qqstars", 1,0, "QQ");
    qmlRegisterType<FriendInfo>("QQItemInfo", 1,0, "FriendInfo");
    qmlRegisterType<GroupInfo>("QQItemInfo", 1,0, "GroupInfo");
    qmlRegisterType<DiscuInfo>("QQItemInfo", 1,0, "DiscuInfo");
    qmlRegisterType<QQItemInfo>("QQItemInfo", 1,0, "QQItemInfo");
    qmlRegisterType<ChatMessageInfo>("QQItemInfo", 1, 0, "ChatMessageInfo");
    qmlRegisterType<ChatMessageInfoList>("QQItemInfo", 1, 0, "ChatMessageInfoList");
    qmlRegisterType<MyImage>("mywindow", 1,0, "MyImage");
    qmlRegisterType<MySvgView>("mywindow", 1, 0, "SvgView");
    qmlRegisterType<MyMessageBox>("mywindow", 1, 0, "MessageBox");
   
    Utility *utility=Utility::createUtilityClass ();
    QNetworkRequest* request = utility->getHttpRequest ()->getNetworkRequest ();
    request->setRawHeader ("Referer", "http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2");//和腾讯服务器打交道需要设置这个
    request->setHeader (QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    
    request = utility->getDownloadImage ()->getHttpRequest ()->getNetworkRequest ();
    request->setRawHeader ("Referer", "http://web2.qq.com/webqq.html");//需要设置这个,不然腾讯服务器不响应你的请求
    request->setRawHeader ("Accept", "image/webp,*/*;q=0.8");
    
    utility->initUtility (new QSettings, engine);
    
    QQmlComponent component0(engine, QUrl("qrc:/qml/Api/QQApi.qml"));
    QQCommand *qqapi = qobject_cast<QQCommand *>(component0.create ());

    engine->rootContext ()->setContextProperty ("myqq", qqapi);
    
    QQmlComponent component(engine, QUrl("qrc:/qml/Utility/SystemTray.qml"));
    SystemTrayIcon *systemTray = qobject_cast<SystemTrayIcon *>(component.create ());
#ifdef Q_OS_WIN
    systemTray->setParent (Utility::createUtilityClass ());//不设置父对象会导致程序退出后托盘还存在的问题
#endif
    engine->rootContext ()->setContextProperty ("systemTray", systemTray);//将程序托盘注册过去
    qqapi->loadLoginWindow ();//加载登录窗口
    
    return app.exec();
}
开发者ID:151706061,项目名称:QQStars,代码行数:61,代码来源:main.cpp


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