diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-17 17:41:58 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-17 17:42:39 (GMT) |
commit | 484a6043ef84df3d0d01a19247ea2c89eb8b309f (patch) | |
tree | 43cbe0e0da00eff1f82a8ac5a641453cb730ce40 /examples | |
parent | 67b7d3ee2c30a710e765252a29ecb9a0ffd0a7a6 (diff) | |
parent | a61adccf96a8ceefbf1150966adda3f6d226ec6d (diff) | |
download | Qt-484a6043ef84df3d0d01a19247ea2c89eb8b309f.zip Qt-484a6043ef84df3d0d01a19247ea2c89eb8b309f.tar.gz Qt-484a6043ef84df3d0d01a19247ea2c89eb8b309f.tar.bz2 |
Merge upstream/4.6 into oslo-staging-2
Diffstat (limited to 'examples')
-rw-r--r-- | examples/network/blockingfortuneclient/blockingclient.cpp | 17 | ||||
-rw-r--r-- | examples/network/fortuneclient/client.cpp | 4 | ||||
-rw-r--r-- | examples/network/fortuneserver/server.cpp | 4 | ||||
-rw-r--r-- | examples/network/network.pro | 1 | ||||
-rw-r--r-- | examples/network/threadedfortuneserver/dialog.cpp | 4 | ||||
-rw-r--r-- | examples/webkit/domtraversal/domtraversal.pro | 2 | ||||
-rw-r--r-- | examples/xmlpatterns/filetree/filetree.pro | 1 |
7 files changed, 27 insertions, 6 deletions
diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp index b731f7a..a3d7c23 100644 --- a/examples/network/blockingfortuneclient/blockingclient.cpp +++ b/examples/network/blockingfortuneclient/blockingclient.cpp @@ -50,7 +50,22 @@ BlockingClient::BlockingClient(QWidget *parent) hostLabel = new QLabel(tr("&Server name:")); portLabel = new QLabel(tr("S&erver port:")); - hostLineEdit = new QLineEdit("Localhost"); + // find out which IP to connect to + QString ipAddress; + QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); + // use the first non-localhost IPv4 address + for (int i = 0; i < ipAddressesList.size(); ++i) { + if (ipAddressesList.at(i) != QHostAddress::LocalHost && + ipAddressesList.at(i).toIPv4Address()) { + ipAddress = ipAddressesList.at(i).toString(); + break; + } + } + // if we did not find one, use IPv4 localhost + if (ipAddress.isEmpty()) + ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); + + hostLineEdit = new QLineEdit(ipAddress); portLineEdit = new QLineEdit; portLineEdit->setValidator(new QIntValidator(1, 65535, this)); diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index ca5d40e..e043f78 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -62,8 +62,10 @@ Client::Client(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 52b7d61..06f6eeb 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -68,8 +68,10 @@ Server::Server(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/network/network.pro b/examples/network/network.pro index 0849271..c5a97fb 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -19,6 +19,7 @@ SUBDIRS = blockingfortuneclient \ symbian: SUBDIRS = qftp contains(QT_CONFIG, openssl):SUBDIRS += securesocketclient +contains(QT_CONFIG, openssl-linked):SUBDIRS += securesocketclient # install sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS network.pro README diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp index b1ea395..d0d3fc0 100644 --- a/examples/network/threadedfortuneserver/dialog.cpp +++ b/examples/network/threadedfortuneserver/dialog.cpp @@ -67,8 +67,10 @@ Dialog::Dialog(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/webkit/domtraversal/domtraversal.pro b/examples/webkit/domtraversal/domtraversal.pro index dda63ba..49400de 100644 --- a/examples/webkit/domtraversal/domtraversal.pro +++ b/examples/webkit/domtraversal/domtraversal.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network FORMS = window.ui HEADERS = window.h SOURCES = main.cpp \ diff --git a/examples/xmlpatterns/filetree/filetree.pro b/examples/xmlpatterns/filetree/filetree.pro index 1683491..4fcf7cb 100644 --- a/examples/xmlpatterns/filetree/filetree.pro +++ b/examples/xmlpatterns/filetree/filetree.pro @@ -2,7 +2,6 @@ SOURCES += main.cpp filetree.cpp mainwindow.cpp ../shared/xmlsyntaxhighlighter.c HEADERS += filetree.h mainwindow.h ../shared/xmlsyntaxhighlighter.h FORMS += forms/mainwindow.ui QT += xmlpatterns -CONFIG -= app_bundle RESOURCES += queries.qrc INCLUDEPATH += ../shared/ |