summaryrefslogtreecommitdiffstats
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* savegame ex.: fix include order [2/2]: game.hMarc Mutz2023-02-081-3/+3
| | | | | | | | | | | | | | | Includes should be ordered from most specific to most general. This means that project-specific includes always come before Qt includes. This example didn't follow that guideline. Fix. Amends 88e8094f18e6581f2b652eb3d82f514ecf687046. Task-number: QTBUG-108857 Change-Id: Iafdae9dd8e70ff99882c4344a023a21d15fa3c54 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit ac6e8b3b21c2ae25e7a4fe483b604ea6ddecd3ff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: make Level ctor explicitMarc Mutz2023-02-081-1/+1
| | | | | | | | | | | A QString is not a full representation of a Level, so the Level(QString) ctor should be explicit. Task-number: QTBUG-108857 Change-Id: I24b705139e61c4aaf59cb0aad3b536013e0d07df Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit fa55d46e1f09ddf45dbe5700d4637b003363c559) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: use ranged instead of indexed loopsMarc Mutz2023-02-082-4/+4
| | | | | | | | | | Modernizes the code, and fixes qsizetype/int mismatch. Task-number: QTBUG-108857 Change-Id: Id4262ee0bcb673d62135a81c30976903eef3e5e2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 44933343937d7a6d9f6afe1f8e0b0f93a387b100) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: use NSDMI, =default the default ctorMarc Mutz2023-02-082-6/+4
| | | | | | | | | | Modernizes the code. Task-number: QTBUG-108857 Change-Id: I6ddf1de3699506ffc0fc4b1034ab48defafcf174 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 35b94f8b4349581c548b7aac2e858750072efa19) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: fix include orderMarc Mutz2023-02-082-3/+4
| | | | | | | | | | | | | Includes should be ordered from most specific to most general. This means that project-specific includes always come before Qt includes. This example didn't follow that guideline. Fix. Task-number: QTBUG-108857 Change-Id: I42727ff8bdef5336368cde349cbcb8d10bb6289f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 88e8094f18e6581f2b652eb3d82f514ecf687046) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: fix extra ';' after Q_GADGETMarc Mutz2023-02-081-1/+1
| | | | | | | | | | | | Fixes compiler warnings. Amends 1ff52e478bab33f3aaba5ec185295411a0e6867d. Task-number: QTBUG-108857 Change-Id: Id8b81c67e55baf490aabd0483b5800b3e61965ee Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 06a9b85f8fec8d039aa0e63cea0e16037611bf79) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Examples: Add missing include guardsFriedemann Kleint2023-02-0112-0/+59
| | | | | | | | | 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> (cherry picked from commit ddb94dd7927126978fc2a620ebd91954e2f96862) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Link update for Data Input Output in the save game exampleJaishree Vyas2023-01-081-1/+1
| | | | | | | Change-Id: I2a886766d59b9e75f42e401fca9c258fcbe02809 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> (cherry picked from commit aae855bd6f87533590b5f91ab7104276d58763ce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix broken linkAndreas Eliasson2023-01-021-5/+5
| | | | | | | | | | | Also, adjust line length to be < 80 columns and make link parenthetical. Fixes: QTBUG-107026 Change-Id: I5f7efa5d572103a6fb432d79a52a57363efd9dd7 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> (cherry picked from commit b556d6227f848d42a10d4f0fc5424bd094e56288) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Wait conditions example: fix an incorrect condition variable usageGiuseppe D'Angelo2022-12-292-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 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit fddeec60cba806b88c5eb0e4758c3951457518a2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Fixes: QTBUG-108860 Change-Id: I2afc77955b95de8aa5fb88048cd9feb217f83b4f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3a449bbb69c9a3c3a5bc6a052f2de98ab79be7e9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Fixes: QTBUG-109119 Change-Id: Ic4bcd010df3fcf82e16385ce241b379f0c351788 Reviewed-by: Christian Strømme <christian.stromme@qt.io> (cherry picked from commit 919664b29a874e8cdc3d74427654cbaa2b61be29) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix typo and mismatch between code and descriptionAndreas Eliasson2022-11-302-2/+2
| | | | | | | | Fixes: QTBUG-107675 Change-Id: I38140617a2b0525db417137aa41a52a389b3bea3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> (cherry picked from commit de7287be69b449b1da13148e62fbeef0406eb792) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Port from qAsConst() to std::as_const()Marc Mutz2022-11-1831-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. This is a 6.4 re-run of the script we ran in dev, in order to avoid conflicts between the branches when cherry-picking. Change-Id: I5eca3df3179dfb2b2682c75a479ba9a4259cc703 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* examples: fix configuring with -no-feature-widgetsJohannes Kauffmann2022-11-021-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. Change-Id: I777e540e6c2101ce8f08a5f80ba01b37ff858373 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 5143670855174d5c86768daf2a4a43c6a0302727)
* Brush up the drop site exampleFriedemann Kleint2022-09-224-24/+33
| | | | | | | | | | | | | - Use qsizetype - Use new string literals instead of deprecated QLatin1String() - Streamline some code - Remove unused member variable - Remove module include Change-Id: Ia96424a23f3ae10e57db942de49949ce3aef8876 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 33bee95910eda6ee06e47753f87e4f140f309721) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Change-Id: I39abb7545d3c68a1a537b865ba3fcb5e60c22fbf Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> (cherry picked from commit 30947c7fd4dddd76b69a3aa11567e27174d7a3ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: I8b57dfa8f88835adae8fceeb122a16635708e338 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit f94f1653368bf8c499fa9a6eeba81736bb2a7710) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add CBOR documentationØystein Heskestad2022-09-027-5/+145
| | | | | | | | | | | | Add documentation of usage of CBOR in convert and cbordump examples, add a CBOR overview, and add links to them other places in the documentation. Task-number: QTBUG-85912 Change-Id: I518792db63647bf9ddd4507d8d4b7ef056192f82 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 855a9ca217ad3b9d8eb8f6544698a174323843fc) Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@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 Change-Id: I00009cb6c8c250a8333ac3dfa635f70da4576d5e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jani Korteniemi <jani.korteniemi@qt.io> (cherry picked from commit 1a6019438881b9aa54cfc8dbd3f8fc06ddc35d67) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Polish the model/view tutorial examplesFriedemann Kleint2022-08-0911-51/+55
| | | | | | | | | | | | | | - Reorder the class declarations, moving private sections last - Make constructors explicit - Add space to the comments - Introduce auto - Replace slot MainWindow::showWindowTitle() by a direct connection to slot QWidget::setWindowTitle(). Change-Id: Ic229162434dfef5f2767d0b4e186759ca0f821f3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 8751ca3daeaa2a500a37b070cdcce5a5bb7a165f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Basiclayouts: Add scrolling to exampleElias Hautala2022-08-081-2/+17
| | | | | | | | | | | | Adds scrolling to basic layouts example because the user interface in the example doesn't fit properly on smaller screen sizes. Fixes: QTCREATORBUG-27634 Change-Id: I61e6eac2b28e5b3ff0f984894fe38167b3f46a9c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Markku Nokkala <markku.nokkala@qt.io> (cherry picked from commit 89ce9a1c5a29e3f420931baa88c705856b99ac25) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Make sure qtbase examples are installed into the correct pathAlexandru Croitor2022-07-273-6/+6
| | | | | | | | | | | The find_package calls need to happen after we set INSTALL_EXAMPLEDIR to ensure that INSTALL_EXAMPLEDIR is overridden if necessary. Task-number: QTBUG-102879 Change-Id: I3c2e6c5a68a8c6ff9b98b79dbd6c83445d8da052 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 818a15234c8fb80cd9adad54bd726cf69726fa79) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Examples: Use signals, slots instead of Q_SIGNALS, Q_SLOTSKai Köhne2022-07-212-3/+3
| | | | | | | Change-Id: I79a352d1bac11edf2d2b0443d2f1bb202fb4e254 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 65d9593413455e401e44006b07c555f27c293add) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Support pinch zoom gesture in the Mandelbrot exampleNicholas Bennett2022-07-214-15/+59
| | | | | | | | | | | | | | | | | | | Used QGesture for this as per the gesture example. Moved the help and info text to separate lines. Enabled word wrap to prevent text going off screen. As a drive-by, the code to center the window at a size that's a fraction of the screen is replaced with a simple sizeHint() override. The user should have control over placement, particularly now that it should be placed manually onto a touchscreen if the user has one. Done-with: Shawn Rutledge Fixes: QTBUG-96702 Change-Id: I8dba8b09bed474f585341e9a7a8c71fb60293eee Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit fc5482cac6e69364c9d09fb8d994065e2a5fb542) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Addressbook example: port to QLatin1StringViewIvan Solovev2022-07-151-3/+5
| | | | | | | | | | | | | This allows to fix the warning: qtbase/examples/widgets/itemviews/addressbook/addresswidget.cpp:115: warning: loop variable ‘str’ of type ‘const QString&’ binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct] Change-Id: Ibbfa7f9e85fe9ef79291f9da3d161667286b282e Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit 7d2361b9da5c1ee9ef0724917108d6a3294e14c2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* GroupBox example: port away from using deprecated QAction::setMenu()Ivan Solovev2022-07-151-3/+1
| | | | | | | | | | | We can achieve the same UI by using QMenu::addMenu() directly Task-number: QTBUG-104857 Change-Id: I627f21bc93646943cf6dfbd3b388352b84f73f0f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 6db91c0df1900df2ddcd5abeb243b8852b02b7ab) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix typos in docs and commentsKai Köhne2022-06-1522-29/+29
| | | | | | | | | | Found by codespell Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 9d2cc4dd766ca6538e17040b6ac845ed880ab0fe) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove unnecessary dependency to OpenGLJoni Poikelin2022-05-301-1/+1
| | | | | | | | The example does not use OpenGL in Qt6 anymore so the dependency is not necessary. Change-Id: I6189a93eb65bd283ea7e85664582ab0b12a41639 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161195-54327/+2404
| | | | | | | | | | | | | 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>
* Replace uses of _qs with _s in sources and examplesSona Kurazyan2022-04-191-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Chip example: fix an accidental bool->int conversion when using PMF connectionsTang Haixiang2022-04-132-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The example was refactored to use the PMF connection syntax. However this introduced a problem: when connecting a QAbstractButton to a slot that has a default parameter, the semantics of the connection change between string-based connections and PMF. Specifically: when connecting the QAbstractButton::clicked(bool checked = false) signal to a slot like View::zoomIn(int level = 1) then a string-based connection like connect(button, SIGNAL(clicked()), this, SLOT(zoomIn())) would call zoomIn without carrying the signal's parameter over. In other words, zoomIn's parameter is defaulted. The same connection using PFM instead is connect(button, &QAbstractButton::clicked, this, &View::zoomIn) which would "connect" the arguments. This makes emissions that pass false as clicked's parameter result in a zoomIn by 0. Fix it by avoiding the default parameter of zoomIn -- just split the function in two (zoomIn and zoomInBy). Amends 8cf812231405e011b422a1505d9a219618fe5cee. Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-100135 Done-with: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Change-Id: I10c150c648034449e3154140108de2d64326d965 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* Examples: Do not depend on transitive includesFabian Kosmale2022-03-174-0/+11
| | | | | Change-Id: I7bba855a14289edbedbaa07a1234213f59085c1d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use QDebugStateSaver in example operator<<()Kai Köhne2022-03-161-1/+2
| | | | | | | | | | This makes sure that changes in the debug stream - like nospace() - do not "leak". Also use the example snippet in QDebugStateSaver documentation. Pick-to: 6.2 6.3 Change-Id: I934976d2c7c2335abfec68c763526a5cbb0e6f1e Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-116-22/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPlatformTextureList holds a QRhiTexture instead of GLuint. A QPlatformBackingStore now optionally can own a QRhi and a QRhiSwapChain for the associated window. Non-GL rendering must use this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still rely on resource sharing between contexts. A widget tells that it wants QRhi and the desired configuration in a new virtual function in QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is evaluated (among a top-level's all children) upon create() before creating the repaint manager and the QWidgetWindow. In QOpenGLWidget what do request is obvious: it will request an OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget) will be more interesting: it needs to honor the standard Qt Quick env.vars. and QQuickWindow APIs (or, in whatever way the user configured the QRhiWidget), and so will set up the config struct accordingly. In addition, the rhiconfig and surface type is (re)evaluated when (re)parenting a widget to a new tlw. If needed, this will now trigger a destroy - create on the tlw. This should be be safe to do in setParent. When multiple child widgets report an enabled rhiconfig, the first one (the first child encountered) wins. So e.g. attempting to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same top-level window will fail one of the widgets (it likely won't render). RasterGLSurface is no longer used by widgets. Rather, the appropriate surface type is chosen. The rhi support in the backingstore is usable without widgets as well. To make rhiFlush() functional, one needs to call setRhiConfig() after creating the QBackingStore. (like QWidget does to top-level windows) Most of the QT_NO_OPENGL ifdefs are eliminated all over the place. Everything with QRhi is unconditional code at compile time, except the actual initialization. Having to plumb the widget tlw's shareContext (or, now, the QRhi) through QWindowPrivate is no longer needed. The old approach does not scale: to implement composeAndFlush (now rhiFlush) we need more than just a QRhi object, and this way we no longer pollute everything starting from the widget level (QWidget's topextra -> QWidgetWindow -> QWindowPrivate) just to send data around. The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split is all gone. Instead, there is a QBackingStoreDefaultCompositor in QtGui which is what the default implementations of composeAndFlush and toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs should continue working mostly as-is, apart from adapting to the texture list changes and getting the native OpenGL texture id out of the QRhiTexture) As QQuickWidget is way too complicated to just port as-is, an rhi manual test (rhiwidget) is introduced as a first step, in ordewr to exercise a simple, custom render-to-texture widget that does something using a (not necessarily OpenGL-backed) QRhi and acts as fully functional QWidget (modeled after QOpenGLWidget). This can also form the foundation of a potential future QRhiWidget. It is also possible to force the QRhi-based flushing always, regardless of the presence of render-to-texture widgets. To exercise this, set the env.var. QT_WIDGETS_RHI=1. This picks a platform-specific default, and can be overridden with QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be extended to query the platform plugin as well to check if the platform plugin prefers to always do flushes with a 3D API. QOpenGLWidget should work like before from the user's perspective, while internally it has to do some things differently to play nice and prevent regressions with the new rendering architecture. To exercise this better, the qopenglwidget example gets a new tab-based view (that could perhaps replace the example's main window later on?). The openglwidget manual test is made compatible with Qt 6, and gets a counterpart in form of the dockedopenglwidget manual test, which is a modified version of the cube example that features dock widgets. This is relevant in particular because render-to-texture widgets within a QDockWidget has its own specific quirks, with logic taking this into account, hence testing is essential. For existing applications there are two important consequences with this patch in place: - Once the rhi-based composition is enabled, it stays active for the lifetime of the top-level window. - Dynamically creating and parenting the first render-to-texture widget to an already created tlw will destroy and recreate the tlw (and the underlying window). The visible effects of this depend on the platform. (e.g. the window may disappear and reappear on some, whereas with other windowing systems it is not noticeable at all - this is not really different from similar situtions with reparenting or when moving windows between screens, so should be acceptable in practice) - On iOS raster windows are flushed with Metal (and rhi) from now on (previously this was through OpenGL by making flush() call composeAndFlush(). Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Do not assume implicit string-ish → QColor conversionMarc Mutz2022-03-111-2/+2
| | | | | | | | We want to mark the corresponding QColor ctor(s) explicit. Use Qt::GlobalColor or the new QColor::fromString() instead. Change-Id: I68bf75a094e6821b97682de5a0ffd975834d22d0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@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>
* 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>
* qtextstream.h: streamline includesFabian Kosmale2022-02-101-0/+1
| | | | | | | | | | | [ChangeLog][Potentially Source-Incompatible Changes] The qtextstream header no longer includes <QString>, <QStringEncoder> and <QStringDecoder>. Code which relied on the implicit inclusion of those classes might now need to include the headers explicitly. Task-number: QTBUG-97601 Change-Id: Ifb8c8452026195a772c0588dbbbc53fb51cac548 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Update Notepad tutorialLeena Miettinen2022-01-316-139/+92
| | | | | | | | | Update to use Qt Creator 7.0 and CMake as the build system. Fixes: QTBUG-100075 Pick-to: 6.3 Change-Id: I71e1d1446a2c79c98423ca5d4427b4b4eb00021b Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* threadedqopenglwidget example: Split out class RendererFriedemann Kleint2022-01-259-310/+441
| | | | | | | | | | | This makes the code clearer and decouples it from the GLWidget. As a drive-by, add a global shortcut to close. Pick-to: 6.3 6.2 Change-Id: I3469d29bc367acc17c5f8acf9d46219259b8315b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Examples: Remove unneeded CMake optionsKai Köhne2022-01-24236-905/+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>
* bindablesubscription: Remove duplicated file entryKai Köhne2021-12-191-1/+0
| | | | | | Pick-to: 6.2 6.3 Change-Id: I7f24425c8ccfb11bda926373099d377f808a70dd Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Examples: Remove unneeded target_include_directoriesKai Köhne2021-12-174-16/+0
| | | | | | Pick-to: 6.3 Change-Id: Icd97815ee231c34ad4ea5ab94a73bfc26df7e0ca Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* mandelbrot example: Remove explicit linking against libmKai Köhne2021-12-172-8/+0
| | | | | | | | It seems not needed anymore with modern toolchains. Pick-to: 6.3 Change-Id: Ic5386cad4576b10f49fd74212f3514e26cfb0abe Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* analogclock example: Clean up link_librariesKai Köhne2021-12-171-5/+1
| | | | | | | | analogclock doesn't use widgets. Pick-to: 6.3 Change-Id: I75b5efc0bec786b45f8273e3d21c9be204e18225 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Examples: Clean up WIN32_EXECUTABLE, MACOSX_BUNDLE propertiesKai Köhne2021-12-1712-66/+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>