本文整理汇总了C++中QNetworkAccessManager::setConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkAccessManager::setConfiguration方法的具体用法?C++ QNetworkAccessManager::setConfiguration怎么用?C++ QNetworkAccessManager::setConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkAccessManager
的用法示例。
在下文中一共展示了QNetworkAccessManager::setConfiguration方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void LiveViewProducer::run(){
LOG_LIVEVIETHREAD_DEBUG << "\n++++++++++++++++++++++++++++++++++++++";
LOG_LIVEVIETHREAD_DEBUG << "LiveViewProducer run\n" << _liveViewRequest;
QNetworkAccessManager liveViewManager;// = new QNetworkAccessManager;
liveViewManager.setConfiguration(_networkConnection->getActiveConfiguration());
QUrl localurl(_liveViewRequest);
QNetworkRequest request(localurl);
liveReply = liveViewManager.get(request);
connect(liveReply, SIGNAL(readyRead()), this, SLOT(onLiveViewManagerReadyRead()));
emit publishProducerStarted();
QThread::exec();
}
示例2: networkAccessible
void tst_QNetworkAccessManager::networkAccessible()
{
QNetworkAccessManager manager;
qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility");
QSignalSpy spy(&manager,
SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::UnknownAccessibility);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility);
QNetworkConfigurationManager configManager;
QNetworkConfiguration defaultConfig = configManager.defaultConfiguration();
if (defaultConfig.isValid()) {
manager.setConfiguration(defaultConfig);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::Accessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
QCOMPARE(spy.count(), 1);
QCOMPARE(QNetworkAccessManager::NetworkAccessibility(spy.takeFirst().at(0).toInt()),
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
}
}
示例3: settings
QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
{
QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent);
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
settings.beginGroup(QLatin1String("QtNetwork"));
const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
settings.endGroup();
// If the saved network configuration is not currently discovered use the system default
QNetworkConfiguration config = manager.configurationFromIdentifier(id);
if ((config.state() & QNetworkConfiguration::Discovered) !=
QNetworkConfiguration::Discovered) {
config = manager.defaultConfiguration();
}
accessManager->setConfiguration(config);
}
return accessManager;
}
示例4: newProxy
void
EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
QNetworkAccessManager* currNam = Echonest::Config::instance()->nam();
TomahawkUtils::NetworkProxyFactory* oldProxyFactory = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( nam->proxyFactory() );
if ( !oldProxyFactory )
{
qDebug() << "Could not get old proxyFactory!";
return;
}
currNam->setConfiguration( nam->configuration() );
currNam->setNetworkAccessible( nam->networkAccessible() );
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() );
QNetworkProxy newProxy( oldProxyFactory->proxy() );
newProxyFactory->setProxy( newProxy );
currNam->setProxyFactory( newProxyFactory );
}
示例5: networkAccessible
void tst_QNetworkAccessManager::networkAccessible()
{
#ifndef QT_NO_BEARERMANAGEMENT
QNetworkAccessManager manager;
qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility");
QSignalSpy spy(&manager,
SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
// if there is no session, we cannot know in which state we are in
QNetworkAccessManager::NetworkAccessibility initialAccessibility =
manager.networkAccessible();
if (initialAccessibility == QNetworkAccessManager::UnknownAccessibility)
QSKIP("Unknown accessibility", SkipAll);
QCOMPARE(manager.networkAccessible(), initialAccessibility);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
int expectedCount = (initialAccessibility == QNetworkAccessManager::Accessible) ? 1 : 0;
QCOMPARE(spy.count(), expectedCount);
if (expectedCount > 0)
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
QCOMPARE(spy.count(), expectedCount);
if (expectedCount > 0)
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
initialAccessibility);
QCOMPARE(manager.networkAccessible(), initialAccessibility);
QNetworkConfigurationManager configManager;
QNetworkConfiguration defaultConfig = configManager.defaultConfiguration();
if (defaultConfig.isValid()) {
manager.setConfiguration(defaultConfig);
QCOMPARE(spy.count(), 0);
if (defaultConfig.state().testFlag(QNetworkConfiguration::Active))
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible);
else
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
if (defaultConfig.state().testFlag(QNetworkConfiguration::Active)) {
QCOMPARE(spy.count(), 1);
QCOMPARE(QNetworkAccessManager::NetworkAccessibility(spy.takeFirst().at(0).toInt()),
QNetworkAccessManager::NotAccessible);
} else {
QCOMPARE(spy.count(), 0);
}
}
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
#endif
}