本文整理汇总了C++中QNetworkConfigurationManager::configurationFromIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkConfigurationManager::configurationFromIdentifier方法的具体用法?C++ QNetworkConfigurationManager::configurationFromIdentifier怎么用?C++ QNetworkConfigurationManager::configurationFromIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkConfigurationManager
的用法示例。
在下文中一共展示了QNetworkConfigurationManager::configurationFromIdentifier方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: settings
//.........这里部分代码省略.........
if (!domain.isEmpty())
hostCombo->addItem(name + QChar('.') + domain);
}
if (name != QString("localhost"))
hostCombo->addItem(QString("localhost"));
// find out IP addresses of this machine
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// add non-localhost addresses
for (int i = 0; i < ipAddressesList.size(); ++i)
{
if (!ipAddressesList.at(i).isLoopback())
hostCombo->addItem(ipAddressesList.at(i).toString());
}
// add localhost addresses
for (int i = 0; i < ipAddressesList.size(); ++i)
{
if (ipAddressesList.at(i).isLoopback())
hostCombo->addItem(ipAddressesList.at(i).toString());
}
quitButton = new QPushButton(tr("Quit"));
sendMessageButton = new QPushButton(tr("Send"));
sendMessageButton->setEnabled(false);
connectButton = new QPushButton(tr("Connect"));
chatBox = new QTextEdit;
chatBox->setReadOnly(true);
messageLineEdit = new QLineEdit;
messageLineEdit->setEnabled(false);
portLineEdit = new QLineEdit;
portLineEdit->setValidator(new QIntValidator(1, 65535, this));
hostLabel->setBuddy(hostCombo);
portLabel->setBuddy(portLineEdit);
statusLabel = new QLabel(tr("This examples requires that you run the "
"Fortune Server example as well."));
tcpSocket = new QTcpSocket(this);
buttonBox = new QDialogButtonBox;
buttonBox->addButton(connectButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(sendMessageButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
mainLayout->addWidget(hostCombo, 0, 1);
mainLayout->addWidget(portLabel, 1, 0);
mainLayout->addWidget(portLineEdit, 1, 1);
mainLayout->addWidget(messageLabel, 2, 0);
mainLayout->addWidget(messageLineEdit, 2, 1);
mainLayout->addWidget(chatBox, 3, 1);
mainLayout->addWidget(statusLabel, 4, 0, 1, 2);
mainLayout->addWidget(buttonBox, 5, 0, 1, 2);
setLayout(mainLayout);
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(sendMessageButton, SIGNAL(clicked()), this, SLOT(sendMessage()));
connect(connectButton, SIGNAL(clicked()), this, SLOT(connectServer()));
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readingMessage()));
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(displayError(QAbstractSocket::SocketError)));
connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(serverDisconnected()));
connect(tcpSocket, SIGNAL(connected()), this, SLOT(disableAddressChange()));
setWindowTitle("Client");
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()));
connectButton->setEnabled(false);
statusLabel->setText(tr("Opening network session."));
networkSession->open();
}
}
示例2: settings
Server::Server(QWidget *parent)
: QDialog(parent)
, statusLabel(new QLabel)
, tcpServer(Q_NULLPTR)
, networkSession(0)
, blockSize(0)
, linkCombo(new QComboBox)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
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, &Server::sessionOpened);
statusLabel->setText(tr("Opening network session."));
networkSession->open();
} else {
sessionOpened();
}
//----------------------------------------------------------------------------------------------------------------
QLabel *youTubeLinksLabel = new QLabel(tr("youTubeLinksLabel:"));
youTubeLinksLabel->setBuddy(linkCombo);
QPushButton *quitButton = new QPushButton(tr("Quit"));
quitButton->setAutoDefault(false);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
buttonLayout->addWidget(quitButton);
buttonLayout->addStretch(1);
//----------------------------------------------------------------------------------------------------------------
connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close);
connect(tcpServer, &QTcpServer::newConnection, this, &Server::storeLink);
//----------------------------------------------------------------------------------------------------------------
QVBoxLayout *mainLayout = Q_NULLPTR;
if (QGuiApplication::styleHints()->showIsFullScreen() || QGuiApplication::styleHints()->showIsMaximized()) {
QVBoxLayout *outerVerticalLayout = new QVBoxLayout(this);
outerVerticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
QHBoxLayout *outerHorizontalLayout = new QHBoxLayout;
outerHorizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored));
QGroupBox *groupBox = new QGroupBox(QGuiApplication::applicationDisplayName());
mainLayout = new QVBoxLayout(groupBox);
outerHorizontalLayout->addWidget(groupBox);
outerHorizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored));
outerVerticalLayout->addLayout(outerHorizontalLayout);
outerVerticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
} else {
mainLayout = new QVBoxLayout(this);
}
mainLayout->addWidget(statusLabel);
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(youTubeLinksLabel);
mainLayout->addWidget(linkCombo);
setWindowTitle(QGuiApplication::applicationDisplayName());
}
示例3: settings
FtpDialog::FtpDialog(QWidget *parent, QString pathToVideoFile, QString videoFileName) :
QDialog(parent)
{
m_pathToVideoFile = pathToVideoFile;
m_videoFileName = videoFileName;
ftp = NULL;
ftpServerLabel = new QLabel(tr("Ftp &server:"), this);
//ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com", this);
ftpServerLineEdit = new QLineEdit("127.0.0.1", this);
ftpServerLabel->setBuddy(ftpServerLineEdit);
statusLabel = new QLabel(tr("Please enter the name of an FTP server."), this);
statusLabel->setWordWrap(true);
fileList = new QTreeWidget(this);
fileList->setEnabled(false);
fileList->setRootIsDecorated(false);
fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
fileList->header()->setStretchLastSection(false);
connectButton = new QPushButton(tr("Connect"), this);
connectButton->setDefault(true);
cdToParentButton = new QPushButton(this);
cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png"));
cdToParentButton->setEnabled(false);
uploadButton = new QPushButton(tr("Upload"), this);
uploadButton->setEnabled(false);
quitButton = new QPushButton(tr("Quit"), this);
QHBoxLayout * buttonBoxLayout = new QHBoxLayout;
buttonBoxLayout->addWidget(uploadButton);
buttonBoxLayout->addWidget(quitButton);
/*buttonBox = new QDialogButtonBox(this);
buttonBox->addButton(uploadButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);*/
progressDialog = new QProgressDialog(this);
connect(quitButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectOrDisconnect()));
connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(processItem(QTreeWidgetItem*,int)));
//connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(enableDownloadButton()));
connect(uploadButton, SIGNAL(clicked()), this, SLOT(uploadFile()));
connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent()));
/*
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));*/
QHBoxLayout * topLayout = new QHBoxLayout;
topLayout->addWidget(ftpServerLabel);
topLayout->addWidget(ftpServerLineEdit);
topLayout->addWidget(cdToParentButton);
topLayout->addWidget(connectButton);
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addLayout(topLayout);
mainLayout->addWidget(fileList);
mainLayout->addWidget(statusLabel);
//mainLayout->addWidget(buttonBox);
mainLayout->addLayout(buttonBoxLayout);
setLayout(mainLayout);
QNetworkConfigurationManager manager;
//qDebug() << manager.capabilities() << "end";
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(enableConnectButton()));
connectButton->setEnabled(false);
quitButton->setEnabled(false);
statusLabel->setText(tr("Opening network session."));
networkSession->open();
}
setWindowTitle(tr("FTP"));
}
示例4: settings
Client::Client(QWidget *parent) : QMainWindow(parent), networkSession(0) {
sysInfo = new QSystemDeviceInfo(this);
QGeoPositionInfo::QGeoPositionInfo(info);
QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
if(source){
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positonUpdated(QGeoPositionInfo)));
source->requestUpdate();
}
hostLabel = new QLabel(tr("&Server name:"));
QString ipAddress;
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
for (int i = 0; i < ipAddressesList.size(); ++i) {
if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
ipAddressesList.at(i).toIPv4Address()) {
ipAddress = ipAddressesList.at(i).toString();
//#############KOSTIL'##################
ipAddress = "91.221.60.166";
break;
}
}
if (ipAddress.isEmpty())
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
hostLineEdit = new QLineEdit(ipAddress);
hostLabel->setBuddy(hostLineEdit);
statusLabel = new QLabel(tr(""));
alarmTypeUnus = new QPushButton(tr("Fire"));
alarmTypeDuo = new QPushButton(tr("Pain"));
alarmTypeTres = new QPushButton(tr("Breakin"));
quitButton = new QPushButton(tr("Quit"));
sendButton = new QPushButton(tr("Send datastring"));
buttonBox = new QDialogButtonBox;
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
tcpSocket = new QTcpSocket(this);
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(alarmTypeUnus, SIGNAL(clicked()), this, SLOT(pressedUnus()));
connect(alarmTypeDuo, SIGNAL(clicked()), this, SLOT(pressedDuo()));
connect(alarmTypeTres, SIGNAL(clicked()), this, SLOT(pressedTres()));
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
mainLayout->addWidget(hostLineEdit, 0, 1);
mainLayout->addWidget(alarmTypeUnus, 3, 0);
mainLayout->addWidget(alarmTypeDuo, 3, 1);
mainLayout->addWidget(alarmTypeTres, 3, 2);
mainLayout->addWidget(buttonBox, 4, 0);
setLayout(mainLayout);
setWindowTitle(tr("Alarm Client"));
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
settings.beginGroup(QLatin1String("QtNetwork"));
const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
settings.endGroup();
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."));
networkSession->open();
}
}
示例5: settings
//! [0]
S2Controller::S2Controller(QWidget *parent): QWidget(parent), networkSession(0)
{
hostLabel = new QLabel(tr("&Server name:"));
portLabel = new QLabel(tr("S&erver port:"));
cmdLabel = new QLabel(tr("Command:"));
QString ipAddress;
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
int portnumber= 1236;
hostLineEdit = new QLineEdit("10.128.48.53");
portLineEdit = new QLineEdit("1236");
portLineEdit->setValidator(new QIntValidator(1, 65535, this));
cmdLineEdit = new QLineEdit;
hostLabel->setBuddy(hostLineEdit);
portLabel->setBuddy(portLineEdit);
statusLabel = new QLabel(tr(" - - - "));
sendCommandButton = new QPushButton(tr("Send Command"));
sendCommandButton->setDefault(true);
sendCommandButton->setEnabled(true);
connectButton = new QPushButton(tr("connect to PrairieView"));
connectButton->setEnabled(true);
quitButton = new QPushButton(tr("Quit"));
getReplyButton = new QPushButton(tr("get reply"));
buttonBox = new QGroupBox;
QVBoxLayout *vb = new QVBoxLayout;
vb->addWidget(sendCommandButton);
vb->addWidget(quitButton);
vb->addWidget(connectButton);
vb->addWidget(getReplyButton);
buttonBox->setLayout(vb);
tcpSocket = new QTcpSocket(this);
connect(hostLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enablesendCommandButton()));
connect(portLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enablesendCommandButton()));
connect(sendCommandButton, SIGNAL(clicked()),
this, SLOT(sendCommand()));
connect(connectButton, SIGNAL(clicked()), this, SLOT(initializeS2()));
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(checkForMessage()));
connect(this, SIGNAL(messageIsComplete()), this, SLOT(processMessage()));
connect(this, SIGNAL(newMessage(QString)),
this, SLOT(messageHandler(QString)));
connect(this, SIGNAL(newMessage(QString)),
this, SLOT(posMonListener(QString)));
connect(quitButton, SIGNAL(clicked()), this, SLOT(sendX()));
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(displayError(QAbstractSocket::SocketError)));
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
mainLayout->addWidget(hostLineEdit, 0, 1);
mainLayout->addWidget(portLabel, 1, 0);
mainLayout->addWidget(portLineEdit, 1, 1);
mainLayout->addWidget(cmdLabel, 2,0);
mainLayout->addWidget(cmdLineEdit,2,1);
mainLayout->addWidget(statusLabel, 3, 0, 1, 2);
mainLayout->addWidget(buttonBox, 4, 0, 1, 2);
setLayout(mainLayout);
setWindowTitle(tr("smartScope2 Controller"));
portLineEdit->setFocus();
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();
}
networkSession = new QNetworkSession(config, this);
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
sendCommandButton->setEnabled(false);
statusLabel->setText(tr("Opening network session."));
networkSession->open();
}
//enablesendCommandButton();
//! [5]
ii =-1;
//.........这里部分代码省略.........