summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-03 12:19:05 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-03 12:19:05 (GMT)
commit6147b21f92b9101f69ed2d916ed005aeb378bdc1 (patch)
treee684f880a7af0267bb756b7d5a2b7eed66eebfb9 /examples
parent77bc072f5b93e43f38eeb31d966fa76a3f6bd61c (diff)
parent5699577461e75093222d6bcd7ce22b0c24a74095 (diff)
downloadQt-6147b21f92b9101f69ed2d916ed005aeb378bdc1.zip
Qt-6147b21f92b9101f69ed2d916ed005aeb378bdc1.tar.gz
Qt-6147b21f92b9101f69ed2d916ed005aeb378bdc1.tar.bz2
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
Diffstat (limited to 'examples')
-rw-r--r--examples/gestures/imageviewer/imageviewer.pro12
-rw-r--r--examples/network/fortuneclient/client.cpp15
-rw-r--r--examples/network/fortuneserver/server.cpp19
3 files changed, 32 insertions, 14 deletions
diff --git a/examples/gestures/imageviewer/imageviewer.pro b/examples/gestures/imageviewer/imageviewer.pro
index efbca00..124175e 100644
--- a/examples/gestures/imageviewer/imageviewer.pro
+++ b/examples/gestures/imageviewer/imageviewer.pro
@@ -1,11 +1,11 @@
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += .
-
-# Input
HEADERS += imagewidget.h \
tapandholdgesture.h
SOURCES += imagewidget.cpp \
tapandholdgesture.cpp \
main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS imageviewer.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer
+INSTALLS += target sources
diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp
index b850a57..7b2991a 100644
--- a/examples/network/fortuneclient/client.cpp
+++ b/examples/network/fortuneclient/client.cpp
@@ -56,7 +56,20 @@ Client::Client(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();
+ }
+ // 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/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index 7564199..476ff283 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -63,15 +63,20 @@ Server::Server(QWidget *parent)
return;
}
//! [0]
- QList<QHostAddress> ipAddresseList = QNetworkInterface::allAddresses();
- QString ipAddresses;
- for (int i = 0; i < ipAddresseList.size(); ++i) {
- ipAddresses.append(ipAddresseList.at(i).toString()).append("\n");
+ 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();
}
-
- statusLabel->setText(tr("The server is running on \n IP: \n%1 PORT: \n%2\n"
+ // if we did not find one, use IPv4 localhost
+ if (ipAddress.isEmpty())
+ ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
+ statusLabel->setText(tr("The server is running on\nIP: \n%1 port:\n%2\n"
"Run the Fortune Client example now.")
- .arg(ipAddresses).arg(tcpServer->serverPort()));
+ .arg(ipAddress).arg(tcpServer->serverPort()));
//! [1]
//! [2]