本文整理汇总了C++中QQmlEngine::setNetworkAccessManagerFactory方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlEngine::setNetworkAccessManagerFactory方法的具体用法?C++ QQmlEngine::setNetworkAccessManagerFactory怎么用?C++ QQmlEngine::setNetworkAccessManagerFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlEngine
的用法示例。
在下文中一共展示了QQmlEngine::setNetworkAccessManagerFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: synchronousNetworkAccessManager
void tst_qqmlengine::synchronousNetworkAccessManager()
{
ImmediateFactory factory;
QQmlEngine engine;
engine.setNetworkAccessManagerFactory(&factory);
QQmlComponent c(&engine, QUrl("myScheme://test.qml"));
// reply is finished, so should not be in loading state.
QVERIFY(!c.isLoading());
}
示例2: if
MainWindow::MainWindow(QWindow *parent)
: QQuickView(parent)
{
setSource(QUrl::fromLocalFile("H:/VK/main.qml").toString());
photoSize = "130";
// !!! SET QNAM AND CACHE
manager = new QNetworkAccessManager(this);
cache = new QNetworkDiskCache(this);
// 500 Mb
cache->setMaximumCacheSize(500*1024*1024);
cache->setCacheDirectory("cacheDir");
manager->setCache(cache);
// SET CACHED NAM TO QMLENGINE TO
MyNetworkAccessManagerFactory* namFactory = new MyNetworkAccessManagerFactory();
QQmlEngine* eng = engine();
eng->setNetworkAccessManagerFactory(namFactory);
QQmlProperty((QObject*)rootObject(), "color").write("#F5F5F5");
QQmlProperty((QObject*)rootObject(), "height").write(height());
wallObj = rootObject();
//wallObj->setProperty("color", "#F5F5F5");
//wallObj->setProperty("height",height());
connect((QObject*)wallObj, SIGNAL(login()),this,SLOT(login()));
connect((QObject*)wallObj, SIGNAL(getGroups()),this, SLOT(getGroups()));
connect((QObject*)wallObj, SIGNAL(getWall(QString)),this, SLOT(getWall(QString)));
connect((QObject*)wallObj, SIGNAL(morePosts()), this, SLOT(morePosts()));
connect((QObject*)wallObj, SIGNAL(setPhotoSize(QString)), this, SLOT(setPhotoSize(QString)));
LoadIni("H:/VK/config.ini");
// do we have token
if( settings->contains("token")){
// its a unlimit token
qDebug() << " HAVE TOKEN ";
if(ReadConfig("expires").toInt()==0){
Token = ReadConfig("token").toString();
}
// if no doesnt it token expire
else if(ReadConfig("expDate").toDate()<=QDate::currentDate()){
Token = ReadConfig("token").toString();
}
// if havent token login
}else{
login();
qDebug() << " NEED LOGIN ";
}
}
示例3: networkAccessManager
void tst_qqmlengine::networkAccessManager()
{
QQmlEngine *engine = new QQmlEngine;
// Test QQmlEngine created manager
QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
QVERIFY(manager != 0);
delete engine;
// Test factory created manager
engine = new QQmlEngine;
NetworkAccessManagerFactory factory;
engine->setNetworkAccessManagerFactory(&factory);
QCOMPARE(engine->networkAccessManagerFactory(), &factory);
QNetworkAccessManager *engineNam = engine->networkAccessManager(); // calls NetworkAccessManagerFactory::create()
QCOMPARE(engineNam, factory.manager);
delete engine;
}