summaryrefslogtreecommitdiffstats
path: root/examples/network
Commit message (Collapse)AuthorAgeFilesLines
...
* Torrent example: Fix some stack overflow issuesMårten Nordheim2023-02-211-2/+2
| | | | | | | | | | | | | | Because of the .size() used as part of the expression it ends up copying sizeof(qsizetype) bytes to the array, instead of the (rationally) expected 4 bytes. Amends 69c31f6f68a1399c1fc1e545e318eaa40966fe85 Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: I732e3f4bb5934ff3860087baa91f9bebbf044a7f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Torrent: simplify QBitArray usageMårten Nordheim2023-02-211-7/+1
| | | | | | | | | | There is specific API for counting number of 0-bits Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: Ifa33862ff7b98a59f362bc52c492e8a037799835 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* examples: Connect Quit action to QCoreApplication::quit, not QWidget::closeTor Arne Vestbø2023-02-204-4/+5
| | | | | | Pick-to: 6.5 Change-Id: I44ca7b61a4a261a7d3aad0dfeb870eb927ee768d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Torrent example: delete unimplemented functionsMårten Nordheim2023-02-141-3/+0
| | | | | | | | | | That's not fit for an example... Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: Ib196d61867f95f3ff2e45841509d49df9360ad25 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Torrent example: Convert some timeouts from int to chronoMårten Nordheim2023-02-144-9/+11
| | | | | | | | | | | | Using seconds because then they all have the same type, even if all-but-one could use minutes. Delete one unused interval value. Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I66b456de8a4b867859e9e2b13ce72e8ec691c79a Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Torrent example: Remove manual little-big endian conversionMårten Nordheim2023-02-141-43/+24
| | | | | | | | | | | | ... and use QtEndian instead. The conversion would be done even on a big-endian system, so the example would not work correctly on such machines. Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I6a660ff68fa5a8d9b4c1faf9e264d937c605c47e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Delete googlesuggestMårten Nordheim2023-02-1411-500/+0
| | | | | | | | | | | As a networking example it doesn't contribute much. But it has some interesting uses of widget/events Pick-to: 6.5 Change-Id: I194d32e6a304ae41819c20751e9f1ee1d9b5abdb Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* HTTP example: Reflow QMessageBox usage in if-statementMårten Nordheim2023-02-021-3/+4
| | | | | | | | | | It gets hard to read like that. And update mentions of 'SSL' to 'TLS' in the message while we're there. Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: Ia7b27bfb3d99391b14ed396ca9a6400621022bf6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Examples: Fix CMake Unity (Jumbo) buildsFriedemann Kleint2023-02-011-2/+2
| | | | | | | | | | Disambiguate variables and add some exclusions. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ie72b3caab9fd571c3fb6f7d8606584885bc09e66 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* Torrent example: Use QByteArray toPercentEncodingMårten Nordheim2023-01-301-6/+2
| | | | | | | | | | | | | | | | The hand-rolled loop produced incorrect output and was subsequently rejected by trackers. The torrent example doesn't support modern features though, so it's still a bit hit-or-miss whether a torrent will work. E.g. downloading an Arch iso does not work since it relies on DHT, PeX and HTTP seeds. Fixes: QTBUG-109798 Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: Ica40fb9205f09d135407a160a28a45d06a418176 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Torrent example: don't try to announce to an empty URLMårten Nordheim2023-01-301-0/+2
| | | | | | | | Task-number: QTBUG-109798 Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I3603232eb094387388da6421bf5525a3ba54fe03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* HTTP Example: Add proxy handlingMårten Nordheim2023-01-242-0/+32
| | | | | | | | | | | If a proxy is configured on the system then we will request credentials if needed. Task-number: QTBUG-108874 Fixes: QTBUG-106245 Pick-to: 6.5 Change-Id: Icbea491492cde4634421b1a1e722a3768d56dec8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* HTTP example: remove needlessly unset-ing window flagMårten Nordheim2023-01-241-2/+0
| | | | | | | | | | In Qt 6 it is unset by default. Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I35af9d7c1517fd393710b7b1b978d3f39c61acf0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* HTTP example: Fix missing translation and improve othersMårten Nordheim2023-01-241-13/+12
| | | | | | | | | As a drive-by: print the path with native separators Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I73164acb159d1a45960e16d5f57996e8c27257f7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* HTTP example: rename to HTTP ClientMårten Nordheim2023-01-242-2/+4
| | | | | | | | | | | It can do more than HTTP but let's keep the naming simple. Most people likely aren't looking to do file: or data: or qrc: in this example. Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I8a822640f4a8015ebf6c56cb6a614d6426e8a912 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fortune* Example: Rename and add category/tagsMårten Nordheim2023-01-244-4/+12
| | | | | | | Task-number: QTBUG-108875 Pick-to: 6.5 Change-Id: I8eeff88187be4f85514d9871eb5009c51ad6de64 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fortune* Example: remove needless unset-ing of window flagMårten Nordheim2023-01-172-2/+0
| | | | | | | | | It's unset by default in Qt6. Task-number: QTBUG-108875 Pick-to: 6.5 Change-Id: I3f1c6e4e6de54e9ca0ed8892f9da1d346d16d4c7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fortune* Example: Bump QDataStream format versionMårten Nordheim2023-01-174-4/+4
| | | | | | | | | | | | | | One of the examples were using a different version than the others. Though QString's formatting probably didn't change since then so it was no problem. Anyway, pretend like we're releasing it now for the first time and set 6.5 on all of them Task-number: QTBUG-108875 Pick-to: 6.5 Change-Id: I28b496ab3d8ff54c503a032ba15882cdf3d5eccf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fortune* Example: convert simple for-loop to ranged-forMårten Nordheim2023-01-174-22/+20
| | | | | | | | | Ends up shortening the loop, making it easier to read at a glance. Pick-to: 6.5 Task-number: QTBUG-108875 Change-Id: Ia12a994259b00e9b57f2de48124be9cb38553bf5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Threaded Fortune Example: update example to use qintptr for descriptorsMårten Nordheim2023-01-172-3/+3
| | | | | | | | Pick-to: 6.5 Task-number: QTBUG-108875 Change-Id: Ie635a3d2c4c61a59547e8fed0ec84da8538968a3 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Examples: Do not wrap custom types in Qt namespaceKai Köhne2023-01-0210-41/+1
| | | | | | | | | | The Qt namespace should be used for types defined in the Qt library, not for user types. Pick-to: 6.5 Change-Id: I6df0ca054888f4a65b19a9cb44324321d1dcfad8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* examples: port network examples to new connection styleSamuel Gaist2022-12-216-6/+6
| | | | | | Task-number: QTBUG-106893 Change-Id: Id0f558362108fedececb9eede36becc04ff4e307 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove showMaximized() workaround for Android in examplesTor Arne Vestbø2022-12-021-4/+0
| | | | | | | Android implements QPlatformIntegration::ShowIsMaximized nowadays. Change-Id: I451a9a8edc8ec407946d44f3e6921c78ac1d11aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Examples: Use PRIVATE CMake linkageKai Köhne2022-11-3021-21/+21
| | | | | | | We (almost) only build apps, for which PRIVATE linkage makes more sense. Change-Id: I09a509c3fb33a00cdfdede687b3f95d638f42091 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Doc: Fix typo and mismatch between code and descriptionAndreas Eliasson2022-11-302-2/+2
| | | | | | | Fixes: QTBUG-107675 Pick-to: 6.4 6.2 Change-Id: I38140617a2b0525db417137aa41a52a389b3bea3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Examples: Use qt_standard_project_setup()Kai Köhne2022-11-1721-48/+42
| | | | | Change-Id: I0ceab08108b7e58e4e2ed25db9e3c289f5c0ddac Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Examples: Use Qt6:: to qualify Qt CMake packagesKai Köhne2022-11-1722-84/+84
| | | | | | | This is what we promote also in the documentation. Change-Id: If91aebafe861b0c934acbb2c69afd182abc3345d Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-118-26/+26
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Replace qExchange with std::exchangeMarc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | None of these users require C++20 constexpr or C++23 noexcept, the only remaining difference between std::exchange and qExchange. This leaves a single qExchange() user, in QScopedValueRollback, that requires the constexpr version, only available from C++20, and thus remains unported. Task-number: QTBUG-99313 Change-Id: Iea46f6ed61d6bd8a5b2fd9d9ec4d70c980b443a2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2322-22/+22
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0322-0/+66
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-16141-6497/+284
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* secure UDP server: do not use deprecated protocol (DTLS 1.0)Timur Pocheptsov2022-03-101-6/+0
| | | | | | | | | | | | And also remove check for DtlsV1_2OrGreater for negotiated session protocol, since it must have been resolved to a specific protocol by this point. Fixes: QTBUG-100154 Pick-to: 6.3 6.2 Change-Id: I3aec31faed8b9cb22be0062da057c62864eba34f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Examples: Remove unneeded CMake optionsKai Köhne2022-01-2421-78/+0
| | | | | | | | | | | | | | | CMAKE_INCLUDE_CURRENT_DIR is not necessary anymore for moc since CMake 3.8: https://cmake.org/cmake/help/latest/release/3.8.html#other-changes CMAKE_AUTORCC should not be used anymore. Instead, we now use qt_add_resources() or similar Enable CMAKE_AUTOUIC only if .ui files are present. Pick-to: 6.3 Task-number: QTBUG-87643 Change-Id: I835e2994cd5dba9918136999499b9077961b616c Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Enable QStyle::State_Horizontal when initializing QStyleOptionProgressBarZhang Hao2022-01-211-1/+1
| | | | | | | | | | | | Since by default QStyleOptionProgressBar is initialized with initialize QStyle::State_Horizontal, the example shouldn't overwrite the state, and instead OR other states into it. Otherwise, the progressbar will be laid out vertically. Pick-to: 6.2 6.3 Fixes: QTBUG-100067 Change-Id: Ibebda48a297af4a621719673033f8199b8bc7984 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Examples: Clean up WIN32_EXECUTABLE, MACOSX_BUNDLE propertiesKai Köhne2021-12-173-15/+0
| | | | | | | | | | | | Both are FALSE by default, so no point in explicitly setting them to FALSE. In addition, dbus/listnames is a command line tool. No reason to set WIN32_EXECUTABLE, MACOSX_BUNDLE here. Pick-to: 6.3 Change-Id: I99aaf27a0267c5575bd2ee5b6183991fce721f44 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Examples: Fix whitespace issues in CMakeLists.txtKai Köhne2021-12-1321-23/+63
| | | | | | Pick-to: 6.3 Change-Id: I8e6dd1f250f8be6016ee4164cb2ab7034cbb1203 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Examples: Remove remaining conversion markers in CMakeLists.txtKai Köhne2021-12-1322-44/+0
| | | | | | Pick-to: 6.3 Change-Id: Ia5d474a3efd6aadbd0ef1537318f2f24e6c24fee Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Prefer unversioned commandsKai Köhne2021-12-132-2/+2
| | | | | | Pick-to: 6.3 Change-Id: Ib32700ab82cf6b271c49e25d12fbad8c9c6bc1d1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Examples: Use find_package(Qt6 REQUIRED COMPONENTS ...) idiomKai Köhne2021-12-1021-78/+21
| | | | | | | | | Also consolidate several find_package(Qt6 ...) calls in one call. Task-number: QTBUG-98867 Change-Id: Idfd5e71f46d4489fac7411cbfadb84437a0658f3 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove .prev_CMakeLists.txtKai Köhne2021-12-061-38/+0
| | | | | | | | These are left-overs from the initial qmake2cmake conversion. Pick-to: 6.2 Change-Id: Ie15c9ff022ea4566d10c1ba74599de9af83d29a7 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* multistreamserver: fix compilationMarc Mutz2021-11-181-1/+1
| | | | | | | | | | | Instead of including <QIODevice>, use the correct 'nested name specifier', QIODeviceBase. Amends 8bd0a09475935cf33f6b7f63a898d4d2e6d43b17. Pick-to: 6.2 Change-Id: I077948b33f985cd4a2e3a9e591645cf20d7af91c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* multistreamclient example: fix compilationMarc Mutz2021-11-161-1/+1
| | | | | | | | | | | | | | Says GCC: qtbase/examples/network/multistreamclient/timeconsumer.cpp:85:37: error: incomplete type ‘QIODevice’ used in nested name specifier 85 | QDataStream ds(&buf, QIODevice::WriteOnly); | ^~~~~~~~~ Instead of including <QIODevice>, use the correct 'nested name specifier', QIODeviceBase. Pick-to: 6.2 Change-Id: Id8d87dbcb497e4feca1d5d3ce6b1bdb9da5c0dab Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Raise cmake_minimum_required to VERSION 3.16 in examplesJoerg Bornemann2021-08-1721-21/+21
| | | | | | | Pick-to: 6.2 Task-number: QTBUG-95636 Change-Id: I1270b4846d8a23bc3563b6942c0910e095d2be4a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove mention of permission api in http exampleAssam Boudjelthia2021-07-301-8/+0
| | | | | | Pick-to: 6.2 Change-Id: I8b22633e1ad5372f92f87315b7184a4b499a0a0b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Rename QPermission namespace to QApplicationPermissionAssam Boudjelthia2021-07-151-2/+3
| | | | | | | | Pick-to: 6.2 Task-number: QTBUG-94407 Change-Id: Ie9c05dbe498cd372c015b5125e6cb8d59ca96b59 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use new permission api for http exampleAssam Boudjelthia2021-06-073-33/+6
| | | | | Change-Id: I265ec42205a193e9862eef26e73805bbf4188640 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Build examples in isolated sub-builds using ExternalProjectCraig Scott2021-05-261-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Examples are intended to show how to build against an installed Qt. Building them as part of the main build means the way the Qt targets are defined and created are not representative of an end user's build. By building them as separate projects using ExternalProject, we can more closely replicate the intended audience's environment. This should allow us to catch more problems earlier. Having examples built as part of the main build also creates problems with some static builds where a tool built by the main build is needed during configure time. This happens with other repos like qtdeclarative but not (currently) with qtbase. Converting the examples in qtbase to be built using ExternalProject is intended as a demonstrator for how other repos can do similar. Until other repos are converted, they will continue to work as they did before, with examples as part of the main build for non-static builds only. The new build-externally behavior is only supported for non-prefix builds with this change. Prefix builds will continue to use the old non-external method. Support for building examples externally in prefix builds will be a separate change. Task-number: QTBUG-90820 Fixes: QTBUG-91068 Change-Id: I2304329940568dbdb7da18d54d5595ea7d8668bc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove unnecessary int() casting in QRandomGenerator::boundedThiago Macieira2021-03-173-10/+10
| | | | | | | | | Commit 21d39168170c6833512c4a5f53985272741bd7e7 added the 64-bit version, so qsizetype now works cross-platform. The casts were added to make qtbase compile on commit df853fed66d891077ae2d04ecfa171d7e2cd5202. Change-Id: I26b8286f61534f88b649fffd166c409c5c232230 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>