summaryrefslogtreecommitdiffstats
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* Don't use file dialog in the address book exampleJan Arve Sæther2023-01-134-19/+17
| | | | | | | | | | | | | | | On small screen devices such as iPhone targets, the save file dialog is using a non-native dialog, and it doesn't fit the screen real estate to the extent that the [Ok] button is clipped away. In addition, the open file dialog and the save file dialog doesn't cooperate very well on platforms such as iOS without more plumbing. Since using the file dialog is out of the scope for this example we remove all usages of it. Pick-to: 6.5 Change-Id: Ie165355ed0b671d93e44d2d55791156367b0ea5c Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* permissions: Improve error when building example on non-supported platformTor Arne Vestbø2023-01-101-1/+4
| | | | | | | Pick-to: 6.5 Change-Id: I02f4fc087d49d21541b1e415db411c09db981278 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Link update for Data Input Output in the save game exampleJaishree Vyas2023-01-051-1/+1
| | | | | | Pick-to: 6.4 6.5 Change-Id: I2a886766d59b9e75f42e401fca9c258fcbe02809 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Fix unused variable compiler warning in slider exampleAxel Spoerl2023-01-051-0/+1
| | | | | | | | | | | The example overrides QWidget::resizeEvent() without using the QResizeEvent * argument. This results in a compiler warning. This patch marks the argument unused. Pick-to: 6.5 Change-Id: I647d0eda7d895e70ed6f232960aec992f5e37b6c Reviewed-by: Shawn Rutledge <shawn.rutledge@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>
* Doc: Fix broken linkAndreas Eliasson2023-01-021-5/+5
| | | | | | | | | | Also, adjust line length to be < 80 columns and make link parenthetical. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-107026 Change-Id: I5f7efa5d572103a6fb432d79a52a57363efd9dd7 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* Wait conditions example: fix an incorrect condition variable usageGiuseppe D'Angelo2022-12-282-15/+16
| | | | | | | | | | | | | | | | | | | | 3a449bbb69c9a3c3a5bc6a052f2de98ab79be7e9 amended the code to remove acquiring a lock when waking up a condition variable. It is fine to not have a lock associated when waking a condition variable; what I misunderstood was the scope of the lock, which (and this underlines the importance of commenting _what exactly_ a lock protects, for each and ever lock) protected both the buffer as well as the counter of the buffer. This made my reasoning flawed: it is necessary to keep the lock while notifying, otherwise the counterpart could verify the condition isn't satisfied and wait (e.g. see numUsedBytes==0), missing the wake from the other thread (which could arrive between the check and the wait). Amends the previous commit. Change-Id: If7db2d045331f1b33b976fb6bf6aa9117c41678f Pick-to: 5.15 6.2 6.4 6.5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* examples: port xml examples to new connection styleSamuel Gaist2022-12-211-9/+9
| | | | | | Task-number: QTBUG-106893 Change-Id: I1cab8949700d7449f0615731c85a77bb9136b0d3 Reviewed-by: Jörg Bornemann <joerg.bornemann@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>
* examples: port qpa examples to new connection styleSamuel Gaist2022-12-211-1/+1
| | | | | | Task-number: QTBUG-106893 Change-Id: Icf9a40403029c6973167f468f51b2dbdc365a848 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* examples: port qmake examples to new connection styleSamuel Gaist2022-12-211-1/+2
| | | | | | Task-number: QTBUG-106893 Change-Id: Ie4a4874359ac7750de344f4e3702ea7be09e7b53 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* examples: port embedded examples to new connection styleSamuel Gaist2022-12-213-13/+14
| | | | | | Task-number: QTBUG-106893 Change-Id: I6d00c53b7747b36c5f0094e566713f13fe74f3de Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* wiggly example: add support for emojis etc. (utf16 surrogate pairs)Eirik Aavitsland2022-12-123-11/+15
| | | | | | | | | | | The venerable wiggly example was created before unicode support was added to Qt. Hence, when extracting the individual characters from the string for painting, the code was not prepared to handle that some characters, like emojis, are composed of two QChar elements. Fixes: QTBUG-28853 Change-Id: I9804415f92775e2b78fa9fcaf7a2d112153cdce0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Remove useless Q_OBJECT in Semaphores exampleAleksandr Reviakin2022-12-071-3/+0
| | | | | | Fixes: QTBUG-108859 Change-Id: I1acf47b9dfd9c38546a2e965baa74067cedffc4a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Wait conditions example: code tidiesGiuseppe D'Angelo2022-12-062-29/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In no particular order: * Clean up #includes. * Document what is protected by the mutex. * Use explicit, nullptr. * Use lock managers, not manual calls to lock/unlock. * Unlock the mutex before notifying the condition variables. * Condition variables are always meant to be used in a while loop, and never with a plain if, because of spurious wakeups. * Don't lock a mutex just to protect a plain integer. We have atomics for that use case. * Remove an unneeded signal, therefore also the need of using Q_OBJECT and the inclusion of the moc-generated file. Pick-to: 5.15 6.2 6.4 Fixes: QTBUG-108860 Change-Id: I2afc77955b95de8aa5fb88048cd9feb217f83b4f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use const reference in loop in JSON Save Game exampleAleksandr Reviakin2022-12-051-1/+1
| | | | | | Fixes: QTBUG-108857 Change-Id: I503a3c9ebe145d0dae52b74435212807405f0247 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CMake: Clean up usage of the examples/widgets/painting/shared libJoerg Bornemann2022-12-055-95/+0
| | | | | | | | | | Remove conversion artifacts. Also, remove setting the include path. The library's interface takes care of that. Change-Id: Ib5043f15ede2171ab876ccbe603ed0b84de1bce4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix examples/widgets/painting/shared libraryJoerg Bornemann2022-12-051-3/+3
| | | | | | | | | | | | This library deliberately links PUBLICly against Qt6::Widgets and Qt6::OpenGL. Same for the target_include_directories call. This partially reverts a5de12f0d7dfef64453b7b29c33dc760b3cacec4. This fixes the builds of examples using this library. Change-Id: I2b5791044afc82e71df4a3bbfc26e5b1ab9afa76 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Avoid continuous texture alloc in Composition Modes exampleLaszlo Agocs2022-12-024-8/+22
| | | | | | | | | | There seems to be some confusion from back when the example were mass-ported to the QOpenGL stuff in Qt 5 times. Pick-to: 6.4 6.2 Fixes: QTBUG-109119 Change-Id: Ic4bcd010df3fcf82e16385ce241b379f0c351788 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Remove Android High-DPI workarounds in examplesTor Arne Vestbø2022-12-023-9/+1
| | | | | | | These should no longer be needed for Qt 6. Change-Id: Ica7214cbf4fc3ddae960309fe89681ec690d28d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove showMaximized() workaround for Android in examplesTor Arne Vestbø2022-12-023-12/+0
| | | | | | | Android implements QPlatformIntegration::ShowIsMaximized nowadays. Change-Id: I451a9a8edc8ec407946d44f3e6921c78ac1d11aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QErrorMessage: Improve standard dialogs exampleTor Arne Vestbø2022-11-302-9/+7
| | | | | Change-Id: Ia5a2251662fe56809fc66cdadd117259d6bfd977 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Examples: Use PRIVATE CMake linkageKai Köhne2022-11-30238-273/+273
| | | | | | | We (almost) only build apps, for which PRIVATE linkage makes more sense. Change-Id: I09a509c3fb33a00cdfdede687b3f95d638f42091 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Examples: Remove duplicated Qt6::PrintSupport link informationKai Köhne2022-11-3011-57/+11
| | | | | | | | Some CMakeLists.txt files did link to Qt6::PrintSupport twice. Also unify formatting and order of the linker step. Change-Id: I4af935c5dc3de6c243aad8511b0803ceaa872589 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>
* Add support for stereoscopic content in QOpenGLWidgetKristoffer Skau2022-11-2812-1/+503
| | | | | | | | | | | | | | | | | Need to add the plumbing necessary to support two textures in QOpenGLWidget and use these in the backing store. The changes required on the RHI level is already done in an earlier patch. Then paintGL() needs to be called twice, once for each buffer. Also add overloads for the other functions of QOopenGLWidget where it makes sense to query for left or right buffer. Then finally create an example. [ChangeLog][Widgets][QOpenGLWidget] Added support for stereoscopic rendering. Fixes: QTBUG-64587 Change-Id: I5a5c53506dcf8a56442097290dceb7eb730d50ce Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add missing qt_standard_project_setup to richtext/textedit exampleJoerg Bornemann2022-11-281-0/+2
| | | | | | | This amends commit f562711c642cba7bed6c96d452437ffc9b25edc4. Change-Id: Iedfb744aa827c7b246aa05eaadd6bc45639d7b61 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Modernize QMessageBox documentation and exampleTor Arne Vestbø2022-11-181-24/+18
| | | | | | Change-Id: Iebcdf53646f1a42c327414edf21ac93a7d1c0a56 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Examples: Use qt_standard_project_setup()Kai Köhne2022-11-17239-503/+476
| | | | | Change-Id: I0ceab08108b7e58e4e2ed25db9e3c289f5c0ddac Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Examples: Use Qt6:: to qualify Qt CMake packagesKai Köhne2022-11-17262-849/+849
| | | | | | | This is what we promote also in the documentation. Change-Id: If91aebafe861b0c934acbb2c69afd182abc3345d Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* sharedmemory example: Handle QSharedMemory::AlreadyExists by attachingTor Arne Vestbø2022-11-152-3/+54
| | | | | | | | Not all platforms clean up the shared memory entries on exit, so the example needs to handle that case, by attaching instead, as documented. Change-Id: Ifbcf92d0fad429caf30710bd8a344831cb0d859c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* sharedmemory example: Show error string when failing to create shared memoryTor Arne Vestbø2022-11-151-1/+2
| | | | | Change-Id: I27edc27aec742e1e34c060e48810c4cfba096ee8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMessageBox: Don't add details button to native dialog helperTor Arne Vestbø2022-11-111-2/+2
| | | | | | | | | | | | | | | The "Show Details..." button is not plumbed in any way to the native dialog, so when added to a native dialog it will just result in the dialog being dismissed, instead of revealing any extra content in the native dialog. Both the iOS and Android native message dialog implementations add the details text directly to the dialog, without any action to explicitly reveal it. Task-number: QTBUG-108153 Change-Id: I92e00c59b7836f633be44caebd534a47ac58be00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add permissions feature example and manual test to the buildAssam Boudjelthia2022-11-103-2/+9
| | | | | | | | | | And add license headers and some minor fixes for warnings in the example and test. Task-number: QTBUG-90498 Change-Id: I34592f7f2844c92c25a6a676c8ac1ffca9e03c6d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Plumb public permission APIs to Android backendTor Arne Vestbø2022-11-092-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | The lock and unlock of the Android deadlock mutex is now part of the internal implementation instead of limited to the enum based permission API. It is unclear why 8bca441b6f65 added the guard only to this API and not to the string based API as well. The check for isBackgroundLocationApi29 has been removed, as the logic seemingly resulted in accepting every single permission type except location permissions if used via the enum-based API. Since Android's platform permission API doesn't have an Undetermined status, we keep a hash of the status for each permission type, and by default checkPermission() would return Undetermined, until a requestPermission() call is done which updates the internal hash, and after that checkPermission() would return properly Granted/Denied. Task-number: QTBUG-100413 Change-Id: Ia95c76af754481a281bc90198e349966c9c2da52 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Exercise QMessageBox::setInformativeText() in standard dialogs exampleTor Arne Vestbø2022-11-031-13/+22
| | | | | Change-Id: Id54a6d93e22fcb6622b434e3766baedb581d6b79 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Add permission API backend for macOS and iOSTimur Pocheptsov2022-11-032-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When submitting applications to the iOS and macOS AppStore the application goes through static analysis, which will trigger on uses of various privacy protected APIs, unless the application has a corresponding usage description for the permission in the Info.plist file. This applies even if the application never requests the given permission, but just links to a Qt library that has the offending symbols or library dependencies. To ensure that the application does not have to add usage descriptions to their Info.plist for permissions they never plan to use we split up the various permission implementations into small static libraries that register with the Qt plugin mechanism as permission backends. We can then inspect the application's Info.plist at configure time and only add the relevant static permission libraries. Furthermore, since some permissions can be checked without any usage description, we allow the implementation to be split up into two separate translation units. By putting the request in its own translation unit we can selectively include it during linking by telling the linker to look for a special symbol. This is useful for libraries such as Qt Multimedia who would like to check the current permission status, but without needing to request any permission of its own. Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Change-Id: Ic2a43e1a0c45a91df6101020639f473ffd9454cc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Long live QPermissions!Tor Arne Vestbø2022-11-012-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many features of today's devices and operating systems can have significant privacy, security, and performance implications if misused. It's therefore increasingly common for platforms to require explicit consent from the user before accessing these features. The Qt permission APIs allow the application to check or request permission for such features in a cross platform manner. The check is always synchronous, and can be used in both library and application code, from any thread. The request is asynchronous, and should be initiated from application code on the main thread. The result of the request can be delivered to lambdas, standalone functions, or regular member functions such as slots, with an optional context parameter to manage the lifetime of the request. Individual permissions are distinct types, not enum values, and can be added and extended at a later point. Task-number: QTBUG-90498 Done-with: Timur Pocheptsov <timur.pocheptsov@qt.io> Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-with: Mårten Nordheim <marten.nordheim@qt.io> Change-Id: I821380bbe56bbc0178cb43e6cabbc99fdbd1235e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Move i18n example to qttoolsKai Köhne2022-11-0139-1240/+0
| | | | | | | | Move i18n example out of qtbase. In qttools, it can use lrelease, avoiding the need to store .qm files in the repository. Change-Id: I8ba36a1372c2a743b809e3f7ea95a67825558f41 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* examples: fix configuring with -no-feature-widgetsJohannes Kauffmann2022-10-291-1/+3
| | | | | | | | | | It also fails for -no-feature-gui, but since the example depends on QtWidgets, which implies depending on QtGui, we only check for QtWidgets here. Pick-to: 6.2 6.4 Change-Id: I777e540e6c2101ce8f08a5f80ba01b37ff858373 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add a shortcut editor exampleLaszlo Papp2022-10-2516-0/+997
| | | | | | | | | | | | | | | Many applications offer shortcuts for quick interaction with the application. It is also common in such applications to offer a shortcut editor in the preferences or separately in a dialog. However, even though this is a fairly common use case for applications with more than a couple of shortcuts, there is no good and comprehensive official Qt example how this could be achieved. This change is an attempt to bridge the gap. Change-Id: Ic01a404e6157bda1b0a75a0b792cbfe5d910d48f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix typo in examples/i18nYAMAMOTO Atsushi2022-10-251-7/+7
| | | | | | | | The name of the variable that handles the qm file is qmlFile. Change-Id: I873c73cd8f96ff821fe3d2e633e84fef8c687875 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-1131-67/+67
| | | | | | | | | | | | | | | | 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>
* Style sheets: add placeholder text color property for edit widgetsEirik Aavitsland2022-09-292-0/+6
| | | | | | | | | The placeholder text was given its own QPalette color role in Qt 5.12, but there has been no way to specify it from a Qt style sheet. Fixes: QTBUG-93009 Change-Id: If58ca844c19c65b7eee14c6d5730a4ba27640c33 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* examples: port dbus examples to new connection styleSamuel Gaist2022-09-271-7/+12
| | | | | | Task-number: QTBUG-106893 Change-Id: Ic857f694b836fba30e41ef0a40107917bd05b64c Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Brush up the drop site exampleFriedemann Kleint2022-09-214-24/+33
| | | | | | | | | | | | - Use qsizetype - Use new string literals instead of deprecated QLatin1String() - Streamline some code - Remove unused member variable - Remove module include Pick-to: 6.4 Change-Id: Ia96424a23f3ae10e57db942de49949ce3aef8876 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Pass a parent pointer to the Animation instance to avoid memory leakJan Arve Sæther2022-09-152-3/+3
| | | | | | | | | The leak is just on termination, but we should show good practices in our examples Pick-to: 6.4 6.3 6.2 Change-Id: I39abb7545d3c68a1a537b865ba3fcb5e60c22fbf Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Use popup() instead of exec() in examplesMikolaj Boc2022-09-072-2/+2
| | | | | | | | | | | popup() is generally better but it has a certain advantage that it does not require a run loop to work, therefore platforms (like WASM) can use it without resorting to extra measures (like asyncify). Task-id: QTBUG-106389 Backport-to: 6.4 6.4.0 Change-Id: I87bde677f84048af82cc9aadd982284bdba41e69 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Document shell-friendly data tags as best practiceEdward Welbourne2022-09-073-8/+7
| | | | | | | | | Also follow this best practice in testlib's own documentation and examples. Pick-to: 6.4 Change-Id: I8b57dfa8f88835adae8fceeb122a16635708e338 Reviewed-by: Paul Wicking <paul.wicking@qt.io>