diff options
Diffstat (limited to 'examples/network/fortuneclient')
-rw-r--r-- | examples/network/fortuneclient/CMakeLists.txt | 33 | ||||
-rw-r--r-- | examples/network/fortuneclient/client.cpp | 17 |
2 files changed, 25 insertions, 25 deletions
diff --git a/examples/network/fortuneclient/CMakeLists.txt b/examples/network/fortuneclient/CMakeLists.txt index 01a8ae4b48..ba55939b37 100644 --- a/examples/network/fortuneclient/CMakeLists.txt +++ b/examples/network/fortuneclient/CMakeLists.txt @@ -4,16 +4,10 @@ cmake_minimum_required(VERSION 3.16) project(fortuneclient LANGUAGES CXX) -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/fortuneclient") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets) +qt_standard_project_setup() + qt_add_executable(fortuneclient client.cpp client.h main.cpp @@ -24,15 +18,22 @@ set_target_properties(fortuneclient PROPERTIES MACOSX_BUNDLE TRUE ) -target_link_libraries(fortuneclient PUBLIC - Qt::Core - Qt::Gui - Qt::Network - Qt::Widgets +target_link_libraries(fortuneclient PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Network + Qt6::Widgets ) install(TARGETS fortuneclient - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET fortuneclient + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index 68fbb68a4e..af7efbd9ed 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -14,7 +14,6 @@ Client::Client(QWidget *parent) , getFortuneButton(new QPushButton(tr("Get Fortune"))) , tcpSocket(new QTcpSocket(this)) { - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); //! [0] hostCombo->setEditable(true); // find out name of this machine @@ -28,16 +27,16 @@ Client::Client(QWidget *parent) if (name != QLatin1String("localhost")) hostCombo->addItem(QString("localhost")); // find out IP addresses of this machine - QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); + const 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()); + for (const QHostAddress &entry : ipAddressesList) { + if (!entry.isLoopback()) + hostCombo->addItem(entry.toString()); } // add localhost addresses - for (int i = 0; i < ipAddressesList.size(); ++i) { - if (ipAddressesList.at(i).isLoopback()) - hostCombo->addItem(ipAddressesList.at(i).toString()); + for (const QHostAddress &entry : ipAddressesList) { + if (entry.isLoopback()) + hostCombo->addItem(entry.toString()); } portLineEdit->setValidator(new QIntValidator(1, 65535, this)); @@ -61,7 +60,7 @@ Client::Client(QWidget *parent) //! [1] in.setDevice(tcpSocket); - in.setVersion(QDataStream::Qt_4_0); + in.setVersion(QDataStream::Qt_6_5); //! [1] connect(hostCombo, &QComboBox::editTextChanged, |