本文整理汇总了C++中QNetworkConfigurationManager::updateConfigurations方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkConfigurationManager::updateConfigurations方法的具体用法?C++ QNetworkConfigurationManager::updateConfigurations怎么用?C++ QNetworkConfigurationManager::updateConfigurations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkConfigurationManager
的用法示例。
在下文中一共展示了QNetworkConfigurationManager::updateConfigurations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QNetworkAccessManager
/**
* @brief CDiscovery::requestNAMgr provides a shared pointer to the discovery services network
* access manager. Note that the caller needs to hold his copy of the shared pointer until the
* network operation has been completed to prevent the manager from being deleted too early.
* Locking: YES (synchronous)
* @return
*/
QSharedPointer<QNetworkAccessManager> CDiscovery::requestNAM()
{
m_pSection.lock();
QSharedPointer<QNetworkAccessManager> pReturnVal = m_pNetAccessMgr.toStrongRef();
if ( !pReturnVal )
{
// else create a new access manager (will be deleted if nobody is using it anymore)
pReturnVal = QSharedPointer<QNetworkAccessManager>( new QNetworkAccessManager(),
&QObject::deleteLater );
m_pNetAccessMgr = pReturnVal.toWeakRef();
// Make sure the networkAccessible state is properly initialized.
QNetworkConfigurationManager manager;
manager.updateConfigurations();
pReturnVal->setConfiguration( manager.defaultConfiguration() );
// QNetworkAccessManager::networkAccessible is not explicitly set when the
// QNetworkAccessManager is created. It is only set after the network session is
// initialized. The session is initialized automatically when a network request is made or
// it can be initialized manually beforehand with QNetworkAccessManager::setConfiguration()
// or by setting the QNetworkConfigurationManager::NetworkSessionRequired flag.
// http://www.qtcentre.org/threads/37514-use-of-QNetworkAccessManager-networkAccessible
// ?s=171a7f69eccb2459cf1cc38507347ead&p=188372#post188372
}
m_pSection.unlock();
return pReturnVal;
}
示例2: main
QT_USE_NAMESPACE
#define NO_DISCOVERED_CONFIGURATIONS_ERROR 1
#define SESSION_OPEN_ERROR 2
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
#ifndef QT_NO_BEARERMANAGEMENT
// Update configurations so that everything is up to date for this process too.
// Event loop is used to wait for awhile.
QNetworkConfigurationManager manager;
manager.updateConfigurations();
QEventLoop iIgnoreEventLoop;
QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit()));
iIgnoreEventLoop.exec();
QList<QNetworkConfiguration> discovered =
manager.allConfigurations(QNetworkConfiguration::Discovered);
foreach(QNetworkConfiguration config, discovered) {
qDebug() << "Lackey: Name of the config enumerated: " << config.name();
qDebug() << "Lackey: State of the config enumerated: " << config.state();
}
示例3: comparison
void tst_QNetworkConfiguration::comparison()
{
//test copy constructor and assignment operator
//compare invalid connection points
QNetworkConfiguration pt1;
QVERIFY(!pt1.isValid());
QVERIFY(pt1.type() == QNetworkConfiguration::Invalid);
QNetworkConfiguration pt2(pt1);
QVERIFY(pt1==pt2);
QVERIFY(!(pt1!=pt2));
QVERIFY(pt1.name() == pt2.name());
QVERIFY(pt1.isValid() == pt2.isValid());
QVERIFY(pt1.type() == pt2.type());
QVERIFY(pt1.state() == pt2.state());
QVERIFY(pt1.purpose() == pt2.purpose());
QNetworkConfiguration pt3;
pt3 = pt1;
QVERIFY(pt1==pt3);
QVERIFY(!(pt1!=pt3));
QVERIFY(pt1.name() == pt3.name());
QVERIFY(pt1.isValid() == pt3.isValid());
QVERIFY(pt1.type() == pt3.type());
QVERIFY(pt1.state() == pt3.state());
QVERIFY(pt1.purpose() == pt3.purpose());
//test case must run on machine that has valid connection points
QNetworkConfigurationManager manager;
QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations();
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations(QNetworkConfiguration::Discovered);
QVERIFY(configs.count());
QNetworkConfiguration defaultConfig = manager.defaultConfiguration();
QVERIFY(defaultConfig.isValid());
QVERIFY(defaultConfig.type() != QNetworkConfiguration::Invalid);
QVERIFY(!defaultConfig.name().isEmpty());
pt3 = defaultConfig;
QVERIFY(defaultConfig==pt3);
QVERIFY(!(defaultConfig!=pt3));
QVERIFY(defaultConfig.name() == pt3.name());
QVERIFY(defaultConfig.isValid() == pt3.isValid());
QVERIFY(defaultConfig.type() == pt3.type());
QVERIFY(defaultConfig.state() == pt3.state());
QVERIFY(defaultConfig.purpose() == pt3.purpose());
}