本文整理汇总了C++中QNetworkInterface::allAddresses方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkInterface::allAddresses方法的具体用法?C++ QNetworkInterface::allAddresses怎么用?C++ QNetworkInterface::allAddresses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkInterface
的用法示例。
在下文中一共展示了QNetworkInterface::allAddresses方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tmp
/* public ***********************************************/
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui_(new Ui::Dialog), Server_(0), Client_(0) {
LOG << "Dialog init.";
ui_->setupUi(this);
QNetworkInterface *inter = new QNetworkInterface();
QList<QHostAddress> list;
list = inter->allAddresses();
QString hostname = "";
for (int i = 0; i < list.size(); ++i) {
QHostAddress tmp(list.at(i).toIPv4Address());
if (tmp.toString().compare("127.0.0.1") && tmp.toString().compare("0.0.0.0"))
hostname = tmp.toString();
}
// ui_->serverIPEdit->setText(hostname);
ui_->serverIPEdit->setText("127.0.0.1");
ui_->serverPortEdit->setText("11111");
ui_->serverMsgEdit->setText("Hello");
// ui_->serverFileEdit->setText("/home/dn/yabss.crt");
ui_->clientIPEdit->setText("127.0.0.1");
ui_->clientPortEdit->setText("11111");
ui_->clientFileWidget->hide();
// ui_->recieveFileEdit->setText("/tmp/");
}
示例2: getMyIP
void getMyIP() {
QNetworkInterface *qni = new QNetworkInterface();
QList<QHostAddress> ips;
QList<QString> ipstr;
QString str;
ips = qni->allAddresses();
for (int i = 0; i < ips.size(); i++)
{
str = ips.at(i).toString();
qDebug() << i << " : " << str;
}
}
示例3: on_actLocalIp_triggered
void MyApp::on_actLocalIp_triggered()
{
QNetworkInterface *test = new QNetworkInterface();
qDebug()<<test->allAddresses();
}