summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Update Sliders exampleVolker Hilsheimer2023-12-194-93/+52
| | | | | | | | | | | | | | | | | | | Simplify the "responsive layout" implementation. Just use a QBoxLayout with changing direction instead of repopulating a QGridLayout, and change the orientation of one set of sliders instead of creating two sets in a stacked layout. Simplify the resizeEvent() implementation accordingly. Update the documentation snippet text to match the code, and document the resizeEvent() override. Fixes: QTBUG-119977 Change-Id: I73a1bb215c956fa283291ebf0ea45ff9a975c727 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit f3fb89ba298e1741320d8bfac9cbd0d503373bff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 2d3ee8ac34bdf30ffc14054a8aeb64ba292bb96e)
* Refurbish the shaped clock exampleMatthias Rauter2023-11-171-21/+34
| | | | | | | | | | | | | The shaped clock example has the appearance of the analog clock, which was refurbished with 619ec1a6406a8be7bfa9d96b9e693e7a3323d8dc. This change applies the refurbished design to the shaped clock. Task: QTBUG-118871 Change-Id: Ibcfc8e9fb239a1c6f7ea685f6cab1e50b2060a53 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f6e7fdd4ad868e5d17ffa7502ed934985df938a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Refurbish the clock exampleMatthias Rauter2023-11-161-26/+48
| | | | | | | | Fixes: QTBUG-118871 Change-Id: I0a1a6444cb381d49adbc39e73d7862c9cfe61dce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 619ec1a6406a8be7bfa9d96b9e693e7a3323d8dc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Convert tooltips example to snippetsVolker Hilsheimer2023-10-2713-528/+0
| | | | | | | | | | The important bits from the example are ~10 lines of code, no need for building a poor-man's version of a graphics or item view. Change-Id: I7874c66765c5b46230c92846ee3de1ee83f47e45 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> (cherry picked from commit ae39b1634556f82fe5d7505ed9b6ebb883d6f813) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move validators example to manual testTor Arne Vestbø2023-06-2915-779/+0
| | | | | | | Change-Id: Ic91bc89422fb23e3782db69bab2953e7cf8ddf69 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit e00d8aa6a83d52b71e3ab2abdb45eafadf65e5f3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move movie example to manual testTor Arne Vestbø2023-06-298-307/+0
| | | | | | | Change-Id: Ie185a3c88eced7b8b0fe324b9ef62ab86d38d521 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit ec01f6ae8b28f6b5cdb125e8e42e18b96f2a97a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move image viewer example to manual testTor Arne Vestbø2023-06-297-518/+0
| | | | | | | Change-Id: I4b64033f1a075681ce5b918fdf2e018ad05a7869 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit b8f588bea74aae0a890e1af18b936b0bfbf8c237) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move digital clock example to manual testTor Arne Vestbø2023-06-297-120/+0
| | | | | | | Change-Id: I043c0060a71d9de2f3e74aab0759d07a20880c3a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 65e7303ec906fb64930772a06fed647f41b54391) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move styles example to manual testTor Arne Vestbø2023-06-2912-805/+0
| | | | | | | Change-Id: I5738932c0c498ce2075a399274e3b80a04ad9211 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 89b463ac2facc1b4fdcf3dcae612a4d8f9109b2c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move tetrix example to manual testTor Arne Vestbø2023-06-2911-782/+0
| | | | | | | Change-Id: Ie73d9e35df8513d05d55ffbad1f02584359e3bd0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 40dbee13ebf8a8d2fdd2fe2fbd82b42ef413a8fd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move stylesheets example to manual testTor Arne Vestbø2023-06-2947-1940/+0
| | | | | | | Change-Id: If0206e63546bf948af4cfb65773e2662c53a5e79 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 1e954f9be898a604499c53fe639e89e8c48a4b0e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move character map example to manual testTor Arne Vestbø2023-06-299-575/+0
| | | | | | | Change-Id: Ie27fe436fc7ae7774beaa78f8a27f6009027753a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3a8265a4290e3405c08811e815edb8432d873a81) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move icons example to manual testTor Arne Vestbø2023-06-2827-979/+0
| | | | | | | Change-Id: I08f44448f96a61f780c21d628954879c7b28dce3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit c3fd8e911ea361df7f1e6fe971f8835d2093db7c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Examples: Remove unnecessary Q_INIT_RESOURCE callsKai Köhne2023-06-144-8/+0
| | | | | | | | | | | | Explicit calls to Q_INIT_RESOURCE are only needed for resources embedded in static libraries. See also https://doc.qt.io/qt-6/resources.html#explicit-loading-and-unloading-of-embedded-resources Change-Id: I06a24d1c04369eedc78ca60a6ca02ce33907d9e7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit eed17b3634a99b6f6f751830c6443094dd6b600b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* shortcuteditor example: Don't reference null-actionTor Arne Vestbø2023-05-171-5/+5
| | | | | | | | | The parent nodes of the leaf ShortcutEditorModelItem nodes do not have an action item. Pick-to: 6.5 Change-Id: If9f8554101974a96f95db048b1bd691f3e89a23a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Revamp the shapedclock exampleVolker Hilsheimer2023-05-162-12/+3
| | | | | | | | | | | | | | | | Rename it to "Translucent Background", as that's what the example shows how to do. And modern applications shouldn't use a (binary) mask to create shaped windows. Instead, set the TranslucentBackground attribute, don't paint pixels that should be fully transparent and use anti-aliased or semi-opaque painting for pixels that should be translucent. Adjust the example and documentation accordingly. Move the statment that widget masks create coarse visual clipping to the QWidget::setMask documentation. Pick-to: 6.5 Change-Id: Id49d854093f2cb471afb178d32723081c7543543 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix pointer mismatch after QList::move() in tooltip exampleAxel Spoerl2023-03-282-18/+26
| | | | | | | | | | | | | | | | | | | | | | | | The tooltip example moves shape items within a QWidget. Shape items are stored in a QList of objects. When an item is moved, its pointer is taken from the QList and stored in a member variable. To have the moved item on the bottom of the list, QList::move() is called. This operation re-arranges the list objects, and the member variable starts pointing at a wrong object. This patch changes the list from a list of objects, to a list of pointers. Shape items are therefore allocated on the heap. A destructor is added to free the heap with qDeleteAll. The example's documentation is adapted accordingly and a snippet for the destructor is added. As a drive-by, int is replaced by qsizetype where it was used as an index of a QList. Fixes: QTBUG-104781 Pick-to: 6.5 6.2 Change-Id: I9be26fa7954be5f85729d24f166d66980af71801 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* examples: port widget examples to new connection styleSamuel Gaist2023-02-254-27/+31
| | | | | | Task-number: QTBUG-106893 Change-Id: Ib10fd516fdbeda0087b1c8550ce340acd3973e6b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Fix qtbase build when all deprecated code are disabledYuhang Zhao2023-02-221-3/+3
| | | | | | | | | Adjust the callers to use the non-deprecated APIs. Pick-to: 6.5 Change-Id: I8e96f25684a2d613bc400a8626dc9e3af2bb8dcf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* examples: Connect Quit action to QCoreApplication::quit, not QWidget::closeTor Arne Vestbø2023-02-201-1/+1
| | | | | | Pick-to: 6.5 Change-Id: I44ca7b61a4a261a7d3aad0dfeb870eb927ee768d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Examples: move widgets/codeeditor into manual testsVolker Hilsheimer2023-02-097-267/+0
| | | | | | | | | | | | | It's not a very well written example, using (largely unneed) hacks to implement what it does. It's also misleading - the syntaxhighlighter example is a better showcase for building a useful code editor. Move it to manual tests. Fixes: QTBUG-111025 Pick-to: 6.5 Change-Id: I405d41688235bf3e9a08373e716769f26d02fec6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Turn elidedlabel example into a code snippetVolker Hilsheimer2023-02-099-343/+0
| | | | | | | | | | | | The example is 90% boiler plate for subclassing QFrame and providing a bit of GUI to change the size of the label using sliders. The interesting bit is a block of 25 lines of code, so turn those into a snippet and add that to the QTextLayout overview documentation. Fixes: QTBUG-111011 Pick-to: 6.5 Change-Id: I6e97b2ea47b553c8d998ad185cfac006721ef7ee Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Remove "Analog Clock Window Example"Jan Arve Sæther2023-02-071-3/+3
| | | | | | | | | | | | This is almost exactly the same as the "Analog Clock" (widget) example. "Analog Clock Window Example" demonstrates: * How to render to a QWindow (covered by RasterWindow example) * QPainter and transformations (covered by Analog Clock example) * How to use QTimer (covered by Analog Clock example) Pick-to: 6.5 Change-Id: I7f20a29798830ed6345eca250e4139cb314cab84 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Examples: Add missing include guardsFriedemann Kleint2023-02-011-0/+5
| | | | | | | | Pick-to: 6.5 6.4 6.2 Task-number: QTBUG-109394 Change-Id: I09a1b522d0faeb2346e1e075141f1e810c8155f7 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove wiggly exampleJan Arve Sæther2023-01-319-210/+0
| | | | | | | | | It demonstrates timerEvent() and some QFontMetrics There are other examples that demonstrates this Pick-to: 6.5 Change-Id: I4ad6f30c8ef93c995f980545ed88ab13b9aa9c7d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove mousebuttons examplesVolker Hilsheimer2023-01-177-304/+0
| | | | | | | | | The example didn't show anything useful, and seemed more like a manual test case. Pick-to: 6.5 Change-Id: Ia71f39b26943aab04b6895e63b6eed50dd084bfd Reviewed-by: Oliver Eftevaag <oliver.eftevaag@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>
* wiggly example: add support for emojis etc. (utf16 surrogate pairs)Eirik Aavitsland2022-12-122-6/+7
| | | | | | | | | | | 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>
* Examples: Use PRIVATE CMake linkageKai Köhne2022-11-3026-29/+29
| | | | | | | 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-302-12/+0
| | | | | | | | 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>
* Examples: Use qt_standard_project_setup()Kai Köhne2022-11-1726-54/+52
| | | | | Change-Id: I0ceab08108b7e58e4e2ed25db9e3c289f5c0ddac Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Examples: Use Qt6:: to qualify Qt CMake packagesKai Köhne2022-11-1726-86/+86
| | | | | | | This is what we promote also in the documentation. Change-Id: If91aebafe861b0c934acbb2c69afd182abc3345d Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add a shortcut editor exampleLaszlo Papp2022-10-2515-0/+767
| | | | | | | | | | | | | | | 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>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-112-2/+2
| | | | | | | | | | | | | | | | 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>
* 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>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2326-26/+26
| | | | | | | 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>
* Sliders: Add function that changes widgets position on layoutElias Hautala2022-08-152-5/+40
| | | | | | | | | | | | | Changes the layout to QGridLayout and adds function to change widgets position on the layout depending on the windows aspect ratio. Before this the widgets wouldn't fit on screen when using the example on Android in portrait. Fixes: QTCREATORBUG-27685 Pick-to: 6.2 6.3 6.4 Change-Id: I00009cb6c8c250a8333ac3dfa635f70da4576d5e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jani Korteniemi <jani.korteniemi@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0326-0/+78
| | | | | | | | | | | | 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>
* GroupBox example: port away from using deprecated QAction::setMenu()Ivan Solovev2022-07-141-3/+1
| | | | | | | | | | We can achieve the same UI by using QMenu::addMenu() directly Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I627f21bc93646943cf6dfbd3b388352b84f73f0f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-16113-5540/+229
| | | | | | | | | | | | | 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>
* examples: add WindowStaysOnBottomHint into preview textLiang Qi2022-05-011-0/+2
| | | | | | Pick-to: 6.3 6.2 5.15 Change-Id: I1e4e390990fcb6e30b2ff7bb59168e4ffc01a936 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CMake: Don't build the movie example if the feature is disabledAlexandru Croitor2022-03-191-1/+3
| | | | | | | Pick-to: 6.2 6.3 Fixes: QTBUG-101897 Change-Id: Idef9aaa0c0a0380b88d8769cb19becd613b2173b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Avoid using deprecated API in the icons exampleEirik Aavitsland2022-02-241-5/+3
| | | | | | | | | Fixes compilation warning. Fixes: QTBUG-100155 Change-Id: I1af2e69c070497509645c933df58fd42277cfb18 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Examples: Remove unneeded CMake optionsKai Köhne2022-01-2425-96/+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>
* Examples: Fix whitespace issues in CMakeLists.txtKai Köhne2021-12-1325-30/+75
| | | | | | 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-1326-57/+3
| | | | | | Pick-to: 6.3 Change-Id: Ia5d474a3efd6aadbd0ef1537318f2f24e6c24fee Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Prefer unversioned commandsKai Köhne2021-12-135-5/+5
| | | | | | 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-1025-77/+31
| | | | | | | | | 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-063-140/+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>
* Remove checks for C++ standard versions C++17 and belowIevgenii Meshcheriakov2021-10-011-9/+0
| | | | | | | | | | | Qt requires a compiler that support C++17 thus __cplusplus is always 201703L or higher. This patch removes checks for __cplusplus value that always succeed. Change-Id: I4b830683ecefab8f913d8b09604086d53209d2e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>