| ID | ... | Creation date | 27 June 2009 |
| Platform | S60 3rd Edition, S60 5th Edition | Tested on devices | Qt Creator IDE |
| Category | Qt for Symbian | Subcategory |
| Keywords (APIs, classes, methods, functions): QNetworkInterface |
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
QNetworkInterface represents one network interface attached to the host where the program is being run. Each network interface may contain zero or more IP addresses, each of which is optionally associated with a netmask and/or a broadcast address.
QNetworkInterface *inter=new QNetWorkInterface(); inter->allAddresses();
QNetworkInterface *inter=new QNetWorkInterface(); inter->allInterfaces();
#ifndef NET_H
#define NET_H
#include <QtGui/QWidget>
#include<QNetworkInterface>
#include<QList>
#include<QLabel>
#include<QHBoxLayout>
#include<QString>
#include<QHostAddress>
#include<QListWidget>
namespace Ui
{
class netClass;
}
class net : public QWidget
{
Q_OBJECT
public:
net(QWidget *parent = 0);
~net();
private:
QNetworkInterface *inter;
QLabel *lbl;
QHBoxLayout *lay;
QListWidget *item;
};
#endif // NET_H
#include "net.h"
#include "ui_net.h"
net::net(QWidget *parent)
: QWidget(parent)
{
QList<QHostAddress> list;
lbl=new QLabel(this);
lay=new QHBoxLayout(this);
item=new QListWidget(this);
inter=new QNetworkInterface(this);
list=inter->allAddresses();
QString str;
for (int i = 0; i < list.size(); ++i) {
str = list.at(i).toString();
item->addItem(str);
}
lay->addWidget(item);
setLayout(lay);
}
net::~net()
{
// No need to delete any object that got a parent that is properly deleted.
}
#include "net.h"
#include "ui_net.h"
net::net(QWidget *parent)
: QWidget(parent)
{
QList<QNetworkInterface> list;
lbl=new QLabel(this);
lay=new QHBoxLayout(this);
item=new QListWidget(this);
inter=new QNetworkInterface(this);
list=inter->allInterfaces();
QString str;
for (int i = 0; i < list.size(); ++i) {
str = list.at(i).name();
item->addItem(str);
}
lay->addWidget(item);
setLayout(lay);
}
net::~net()
{
}
No related wiki articles found