本文整理汇总了C++中QNetworkConfigurationManager::capabilities方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkConfigurationManager::capabilities方法的具体用法?C++ QNetworkConfigurationManager::capabilities怎么用?C++ QNetworkConfigurationManager::capabilities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkConfigurationManager
的用法示例。
在下文中一共展示了QNetworkConfigurationManager::capabilities方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openConnection
bool Network::openConnection(QString &netInterface)
{
// Internet Access Point
QNetworkConfigurationManager manager;
const bool canStartIAP = (manager.capabilities()
& QNetworkConfigurationManager::CanStartAndStopInterfaces);
// If there is a default access point, use it
QNetworkConfiguration cfg = manager.defaultConfiguration();
if (!cfg.isValid() || !canStartIAP) {
return false;
}
// Open session
m_session = new QNetworkSession(cfg);
m_session->open();
// Waits for session to be open and continues after that
m_session->waitForOpened();
// Show interface name to the user
QNetworkInterface iff = m_session->interface();
netInterface = iff.humanReadableName();
return true;
}
示例2: settings
Client::Client(QString purpose) : networkSession(0)
{
Client::purpose = purpose;
tcpSocket = new QTcpSocket;
Client::blockSize = 0;
qDebug() << connect(tcpSocket, &QTcpSocket::readyRead, this, &Client::readData);
//connect(tcpSocket, &QTcpSocket::error, this, &Client::displayError);
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
{
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
qDebug() << connect(networkSession, &QNetworkSession::opened, this, &Client::sessionOpened);
}
qDebug() << "Client set up, waiting";
}
示例3: settings
Server::Server()
{
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
{
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
if (networkSession)
{
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
TRACE_INFO(NET, "Opening network session...\n");
networkSession->open();
}
}
else
{
sessionOpened();
}
fortunes << tr("You've been leading a dog's life. Stay off the furniture.")
<< tr("You've got to think about tomorrow.")
<< tr("You will be surprised by a loud noise.")
<< tr("You will feel hungry again in another hour.")
<< tr("You might have mail.")
<< tr("You cannot kill time without injuring eternity.")
<< tr("Computers are not intelligent. They only think they are.");
if (tcpServer)
{
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendDatas()));
}
/*
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
buttonLayout->addWidget(quitButton);
buttonLayout->addStretch(1);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(statusLabel);
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
setWindowTitle(tr("Fortune Server"));
*/
}
示例4: settings
Server::Server(QObject *parent) :
QObject(parent), tcpServer(0), networkSession(0), memBuf(NULL)
{
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
QTextStream out(stdout);
out << tr("Opening network session.");
networkSession->open();
} else {
sessionOpened();
}
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendImage()));
}
示例5: init
bool TCPClientProducer::init()
{
assert( m_networkSession == 0 );
assert( m_tcpSocket != 0 );
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();
}
m_networkSession = new QNetworkSession(config);
connect(m_networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
qDebug() << "Opening network session.";
m_networkSession->open();
}
return true;
}
示例6: StartServer
void Server::StartServer()
{
shotTimer->stop();
is_config_mode = false;
emit write_message(tr("Network session starting."));
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpen()));
emit write_message(tr("Opening network session."));
networkSession->open();
} else {
sessionOpen();
}
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(recieveConnection()));
}
示例7: settings
BigBlobbyClient::BigBlobbyClient() :
networkSession_( NULL ),
tcpSocket_( new QTcpSocket( this ) ),
portNumber_( DEFAULT_PORT_NUMBER ),
log_( logger::FileLogger::instance() )
{
connect( tcpSocket_, SIGNAL( readyRead() ), this, SLOT( readBigBlobbyResponse() ) );
connect( tcpSocket_, SIGNAL( error( QAbstractSocket::SocketError ) ),
this, SLOT( displayError( QAbstractSocket::SocketError ) ) );
QNetworkConfigurationManager manager;
if( manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired ) {
// Get saved network configuration
QSettings settings( QSettings::UserScope, QLatin1String( "BigBlobby" ) );
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();
}
networkSession_ = new QNetworkSession( config, this );
connect( networkSession_, SIGNAL( opened() ), this, SLOT( sessionOpened() ) );
networkSession_->open();
}
}
示例8: settings
Server::Server(QWidget *parent) :
QDialog(parent),
mTcpServer(0),
mNetworkSession(0) {
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();
}
mNetworkSession = new QNetworkSession(config, this);
connect(mNetworkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
mNetworkSession->open();
} else {
sessionOpened();
}
mIPAddressMapper = new QSignalMapper;
connect(mTcpServer, SIGNAL(newConnection()), this, SLOT(acceptClientConnection()));
connect(mIPAddressMapper, SIGNAL(mapped(QString)), this, SIGNAL(clientDisconnected(QString)));
}
示例9: settings
Server::Server(QWidget *parent) : QDialog(parent)
{
networkSession=0;
tcpServer=0;
ui = new Ui::Server;
ui->setupUi(this);
val=0;
ui->quit_button->setAutoDefault(false);
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
networkSession->open();
} else {
sessionOpened();
}
connect(ui->quit_button, SIGNAL(clicked()), this, SLOT(close()));
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(conn()));
}
示例10: QString
void
Loco::RunSlippy ()
{
mainUi.displayMap->SetLocator (locator);
// Set Internet Access Point
QNetworkConfigurationManager manager;
const bool canStartIAP = (manager.capabilities()
& QNetworkConfigurationManager::CanStartAndStopInterfaces);
// Is there default access point, use it
QNetworkConfiguration cfg1 = manager.defaultConfiguration();
if (!cfg1.isValid() || (!canStartIAP && cfg1.state() != QNetworkConfiguration::Active)) {
networkSetupError =
QString(tr("This example requires networking, "
"and no avaliable networks or access points "
"could be found."));
QTimer::singleShot(0, this, SLOT(networkSetupError()));
return;
}
netSession = new QNetworkSession(cfg1, this);
conHelp = new ConnectivityHelper (netSession, this);
connect (netSession, SIGNAL (opened()),
this, SLOT (networkSessionOpened ()));
connect (conHelp, SIGNAL (networkingCancelled()),
this, SLOT (Quit()));
}
示例11: connect
lc::ClientHelpNotificationServer::ClientHelpNotificationServer( QObject *argParent ) :
QObject{ argParent },
hostAddress{ settings->serverIP }
{
QNetworkConfigurationManager manager;
if ( manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired ) {
// Get saved network configuration
QSettings settings{ QSettings::UserScope, QLatin1String{ "QtProject" } };
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();
}
networkSession = new QNetworkSession{ config, this };
connect( networkSession, &QNetworkSession::opened,
this, &ClientHelpNotificationServer::OpenSession );
networkSession->open();
} else {
OpenSession();
}
connect( helpMessageServer, &QTcpServer::newConnection,
this, &ClientHelpNotificationServer::SendReply );
}
示例12: settings
TcpEchoServer::TcpEchoServer(quint16 port, QObject *parent)
: QObject(parent), tcpServer(0), networkSession(0)
{
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
qDebug() << "Opening network session.";
networkSession->open();
} else {
sessionOpened(port);
}
}
示例13: settings
Server::Server(QWidget *parent) :
QDialog(parent), tcpServer(0), clientSocket(0), networkSession(0),
blockSize(0)
{
serverStatusLabel = new QLabel(tr("Status"));
messageLabel = new QLabel(tr("Message:"));
quitButton = new QPushButton(tr("Quit"));
quitButton->setAutoDefault(false);
sendMessageButton = new QPushButton(tr("Send Message"));
chatBox = new QTextEdit;
chatBox->setReadOnly(true);
messageLineEdit = new QLineEdit;
messageLineEdit->setEnabled(false);
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
{
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
serverStatusLabel->setText("Opening network session.");
networkSession->open();
}
else
sessionOpened();
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(serverStatusLabel, 0, 0);
mainLayout->addWidget(messageLabel, 2, 0);
mainLayout->addWidget(messageLineEdit, 3, 0);
mainLayout->addWidget(sendMessageButton, 4, 0);
mainLayout->addWidget(chatBox, 5, 0);
mainLayout->addWidget(quitButton, 6, 0, 1, 2);
setLayout(mainLayout);
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(sendMessageButton, SIGNAL(clicked()), this, SLOT(sendMessage()));
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(clientProcessing()));
setWindowTitle("Server");
}
示例14: settings
Server::Server(/* QWidget *parent */)
: /*QDialog(parent),*/ tcpServer(0), networkSession(0)
{
//statusLabel = new QLabel;
//quitButton = new QPushButton(tr("Quit"));
//quitButton->setAutoDefault(false);
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
///statusLabel->setText(tr("Opening network session."));
std::cout << "Opening network session." << std::endl;
networkSession->open();
} else {
sessionOpened();
}
fortunes << tr("bla bla bue ee ee e e.")
<< tr("You've got to think about tomorrow.")
<< tr("You wi Q_OBJECTll be surprised by a loud noise.")
<< tr("You will feel hungry again in another hour.")
<< tr("You might have mail.")
<< tr("You cannot kill time without injuring eternity.")
<< tr("Computers are not intelligent. They only think they are.");
///connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune()));
// QHBoxLayout *buttonLayout = new QHBoxLayout;
// buttonLayout->addStretch(1);
// buttonLayout->addWidget(quitButton);
// buttonLayout->addStretch(1);
// QVBoxLayout *mainLayout = new QVBoxLayout;
// mainLayout->addWidget(statusLabel);
// mainLayout->addLayout(buttonLayout);
// setLayout(mainLayout);
// setWindowTitle(tr("Fortune Server"));
}
示例15: QWidget
RSSListing::RSSListing(QWidget *parent)
: QWidget(parent), currentReply(0)
{
#ifdef Q_OS_SYMBIAN
// Set Internet Access Point
QNetworkConfigurationManager manager;
const bool canStartIAP = manager.capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces;
// Is there default access point, use it
QNetworkConfiguration cfg = manager.defaultConfiguration();
if (!cfg.isValid() || !canStartIAP) {
// Available Access Points not found
QMessageBox::warning(this, "Error", "No access point");
return;
}
m_session = new QNetworkSession(cfg);
m_session->open();
m_session->waitForOpened();
#endif
lineEdit = new QLineEdit(this);
lineEdit->setText("http://labs.qt.nokia.com/blogs/feed");
fetchButton = new QPushButton(tr("Fetch"), this);
treeWidget = new QTreeWidget(this);
connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
this, SLOT(itemActivated(QTreeWidgetItem*)));
QStringList headerLabels;
headerLabels << tr("Title") << tr("Link");
treeWidget->setHeaderLabels(headerLabels);
treeWidget->header()->setResizeMode(QHeaderView::ResizeToContents);
connect(&manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(finished(QNetworkReply*)));
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(fetch()));
connect(fetchButton, SIGNAL(clicked()), this, SLOT(fetch()));
QVBoxLayout *layout = new QVBoxLayout(this);
QHBoxLayout *hboxLayout = new QHBoxLayout;
hboxLayout->addWidget(lineEdit);
hboxLayout->addWidget(fetchButton);
layout->addLayout(hboxLayout);
layout->addWidget(treeWidget);
setWindowTitle(tr("RSS listing example"));
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5)
resize(640,480);
#endif
}