summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets
Commit message (Collapse)AuthorAgeFilesLines
* QMetaProperty: Introduce VIRTUAL, OVERRIDE attributesDmitrii Akshintsev13 days1-0/+2
| | | | | | | | | | [ChangeLog][QML] VIRTUAL and OVERRIDE attributes will be used for the expanded override semantics in QML. See QTBUG-98320 for the details. Task-number: QTBUG-98320 Change-Id: I56826a6b9158c0beeb58ad1564a58c22f15027bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Document QFuture::cancelChain() limitationsIvan Solovev2025-12-041-0/+24
| | | | | | | | | | | Explicitly mention that cancelChain() cannot cancel a nested QFuture once the related computation has started. The user needs to explicitly capture and cancel the nested future instead. Task-number: QTBUG-140786 Pick-to: 6.10 Change-Id: Icc629071659a5833f7e9b55c640fd9920b6bd8a9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add QRangeModelAdapter: C++-style access to the range while talking QAIMVolker Hilsheimer2025-12-042-0/+367
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a QRangeModel represents a C++ range, then the C++ range must no longer be modified directly, as clients of the model won't be notified about data or structural changes. Ignoring this (documented) warning might end up with views not presenting the data correctly, or even result in crashes as the model cannot update QPersistentModelIndex instances. Modifying the range through the QAbstractItemModel API is ok, but clumsy, as it requires dealing with QModelIndex and QVariant for basic operations. QRangeModelAdapter provides an easy, type safe, and data-structure aware API for reading and also modifying a range that a QRangeModel operates on. This includes an interator API for rows, and - unless the range is a list - columns. Dereferencing row iterators yields a row reference type from which a row can be accessed for reading, or that a new row can be assigned to. Dereferencing a const column iterator yields an item; dereferencing a mutable column iterator yields a reference type that a new item value can be assigned to. Since QRangeModel itself is not a template class (so we don't know the type of the range anymore once it has been created), we have to create the adapter from the range (and optional protocol), which then implicitly creates the model. Constructing the adapter implicitly constructs the model, which is owned by the adapter. QRangeModelAdapter is a value type, using std::shared_ptr for the model so that all copies of the adapter operate on the same model. To be able to set entire multi-role objects as items, introduce a new Qt::ItemDataRole enum value, Qt::RangeModelAdapterRole. This is very similar to Qt::RangeModelDataRole, but QML has specific requirements that QRangeModelAdapter doesn't have, and we want to pass items back and forth without modifying their value category - ie. an item that is a shared_ptr<Object> is not useful for QML (which needs an Object *), but a C++ user expects to get a shared_ptr<Object> from a call to at(), and also expects to be able to set such an item. The code has room for de-duplicating some logic in follow-up commits. [ChangeLog][Core] Added QRangeModelAdapter for C++-style access to a range used in a QRangeModel, while implementing QAbstractItemModel protocol. Change-Id: I3f2f94cb51b850100590fbe2c9a7c9dabbec59bd Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Core: Provide non-broken metacontainer iterablesUlf Hermann2025-12-021-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSequentialIterable and QAssociativeIterable are incapable of providing operator[] on their iterators because the references used by those iterators are not actually stable when the iterator is modified. The only way to fix this in a binary compatible way is to provide a complete set of new iterables and iterators. These are implemented in qmeta{association|sequence}.h and exposed through QMeta{Association|Sequence}::Iterable. In order to give users a convenient way to include those, we instruct syncqt to regard qmeta{association|sequence}.h as header to use in order to provide QMetaSequence and QMetaAssociation. These headers are the natural choice anyway. qmetacontainer.h still has to hold the (now incomplete) declarations for QMetaSequence and QMetaAssociation so that we remain source compatible. The new iterables offer a more consistent set of accessor methods and deprecate some of the old accessor methods. It makes little sense to add or remove a value from/to an iterable at an unspecified place. The new sequential iterable offers the more familiar append/prepend and removeFirst/removeLast methods. Finally, the new iterables warn when taking a slow code path that synthesizes operations not avaible on the actual container using iterators. There generally is a reason for those operations to not be available and we shouldn't second-guess the choices made by the authors of the container. For now, we have to keep those code paths intact to remain compatible with QSequentialIterable and QAssociativeIterable. Task-number: QTBUG-140181 Change-Id: I2f4c32716951fa023ae1fb8028d1a87e4c85c3a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix no-gui developer buildJoerg Bornemann2025-11-251-1/+1
| | | | | | | | The eventfilters doc snippet needs at least Qt Gui. Put its add_subdirectory call into a QT_FEATURE_gui check scope. Change-Id: I6c79ccd0f4d668e353584b61b6ff8c1898d50962 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Prefer using namespace Qt::StringLiteralsMarc Mutz2025-10-042-2/+2
| | | | | | | | | | | | | | | | | ... over Qt::Literals::StringLiterals. The latter works, but is needlessly verbose. Since such code is copy'n'pasted, use the preferred form everywhere, to avoid proliferation. The docs have been fixed to suggest the shortcut in a separate commit. As a drive-by, move them to their preferred location, after the QT_BEGIN_NAMESPACE, but only if they were far away to begin with. Pick-to: 6.10 6.8 6.5 Change-Id: I0325f749f3b5a331d9c6af458a9bd3bb70d4aa3b Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix corelib snippet compilationIvan Solovev2025-09-121-1/+0
| | | | | | | | | | | | | | The src_corelib_thread_qexception.cpp snippet was added twice: * first time - unconditionally * second time - properly guarded by QT_FEATURE_concurrent Keep only the second addition of this file, which is properly guarded. Amends c1889bd953892428a474822168c10a4f983fb3ae. Change-Id: I1efcbd266e8b6d355d8083b2f74346af667d3b8b Reviewed-by: Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* wasm: Fix corelib snippetsPiotr Wiercinski2025-09-112-10/+18
| | | | | | | Change-Id: Ifaf2c6dd3ff5c97f9c7eef71d397ee8d58cdb4c4 Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io>
* Doc: Modernize QHash iterator documentationPaul Wicking2025-09-091-2/+18
| | | | | | | | | | | | | | | | | | | | | | Promote STL-style iterators as the primary way to iterate over QHash. Replace the detailed explanation with direct guidance to use QHash::asKeyValueRange, and move Java-style iterators to a brief compatibility note. Update snippets to: - Show C++17 structured bindings with std::as_const(hash).asKeyValueRange() (add <utility> header std::as_const). - Add STL-style iterator example for manual control. - Add example for modifying values in place. This makes the docs clearer, const-correct, and aligned with modern C++ usage. Fixes: QTBUG-139662 Pick-to: 6.10.0 6.10 6.9 6.8 Change-Id: Ifb9698b93ca53c3c6a7c82b0f1d393105cd62f35 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QRM docs: clarify direct access to the range, add section on subclassingVolker Hilsheimer2025-08-291-0/+30
| | | | | | | | | | | | | | | Those two are related: if we really didn't allow direct access to the range after QRangeModel has been constructed, then subclassing would be practically impossible. We do allow it, as long as no view (or similar) operates on the model. Clarify that in the \note, and add a snippet showing how to subclass QRangeModel to build an encapsulated class that provides type- and structure-aware APIs. Pick-to: 6.10 Change-Id: I43836c750e372fd55c63bb75d89109524c87206c Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Fix snippet compilation in corelibIvan Solovev2025-08-294-10/+8
| | | | | | | | | | | | | | | | | | | | The snippets use deprecated APIs, so the compilation fails when building with QT_DISABLE_DEPRECATED_UP_TO set to a recent Qt version. Fix it by wrapping the relevant code in the proper #ifdefs. In QCoreApplication snippet, updeted QMouseEvent to use the modern API. Remove the foreach() examples from the QVariant docs, because the usage of foreach() is discouraged. Amends: * c1889bd953892428a474822168c10a4f983fb3ae for QDateTime snippets * 55dc3ddaa7523a3e470c98271ea55fc7d2f3c414 for qglobal snippets * d9251a64367e15f234718d9b3ed88d2f7bcfd0c6 for the rest Change-Id: Idba2c115e2efb66b4cec707296ddfc38de9f9d25 Reviewed-by: Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CMake: Don't use private CMake API in doc snippetsAlexandru Croitor2025-08-215-52/+72
| | | | | | | | | | | | | | | | | | | Private CMake API like qt_internal_extend_target should not be used in public doc snippets. While most of the CMakeLists.txt doc snippets might not appear in the documentation right now, they might in the future (just like the CMake API doc snippets). In addition, using private CMake API for doc snippets targets causes issues with SBOM generation, because the original targets are not created with private API (e.g. qt_internal_add_module vs qt_add_library), and thus important sbom meta information is missing, causing errors at cmake configure time when sbom generation is enabled. Pick-to: 6.8 6.9 6.10 Change-Id: I2ef80f617ba8b745520408d22dd2e6be5ee4c5e0 Reviewed-by: Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QDirListing: clarify that "name filters" use regular expressionsAhmad Samir2025-08-101-0/+15
| | | | | | | | | Also add a code snippet showing how filtering can be done by name using QString API, without regex. Pick-to: 6.10 6.9 6.8 Change-Id: Iee63da4590e4868f3dc3d8db0e99ba9bf64a4e0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update of doc snippet for implicit sharing exampleOleksii Zbykovskyi2025-08-042-22/+2
| | | | | | | | | Snippet 0 was uncompileable because of the QPenPrivate. Changed this snippet to the actual QPen implementation. And added priviously uncompilable file to the build system. Change-Id: I8c108f5c4982e26697a68a8a0ed8e3eee7b1019a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Skip doc snippets that depend on QProcess when feature is unavailableTor Arne Vestbø2025-07-302-5/+21
| | | | | Change-Id: I382025b9e2276acde914f8c5844e25c73978bd55 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Snippets: fix unity buildsTim Blechmann2025-07-301-0/+4
| | | | | | | | | Snippets contain duplicate functions / structs, so they break unity builds. Disabling unity builds fixes compilation again. Change-Id: I4d9e70dbc8107204c244167ce4396a29be2f08c3 Reviewed-by: Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make the confusing variable name in qt_add_resources docs lowercaseAlexey Edelev2025-07-291-3/+3
| | | | | | Pick-to: 6.8 6.9 6.10 Change-Id: Ic3cc4261481a1e8218837046f0da91364470b14b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Make last files in code folder compilableOleksii Zbykovskyi2025-07-294-32/+72
| | | | | | | | Fixed small issues in each of the files and added to the build system. Task-number: QTBUG-137566 Change-Id: Iabe88b38c43f2db527027a0518840f16091898ad Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of files under tools prefixOleksii Zbykovskyi2025-07-2920-1379/+1867
| | | | | | | | Made each file compilable and added them to the build system. Task-number: QTBUG-137566 Change-Id: I51aac946a1bfd8922c6a3669483d4e6f591795b5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make files under thread and time prefix compilableOleksii Zbykovskyi2025-07-2912-901/+1233
| | | | | | | | Make these file compilable and add to the build system. Task-number: QTBUG-137566 Change-Id: I3edf8204428a1e619fe5049e5d46ae51c6900002 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCborStream code snippet: Explicitly construct qfloat16 from floatAxel Spoerl2025-07-291-2/+2
| | | | | | | | | | | Direct assignment of a float to a qfloat16 with operator= fails to compile with "conversion from ‘float’ to non-scalar type ‘qfloat16’ requested". Explicitly use the float constructor of qfloat16. Change-Id: I3e55478887bc191125479044120e081edba34b1c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix files under text prefix and add to the build systemOleksii Zbykovskyi2025-07-2513-1033/+1251
| | | | | | | | Made each file under the text prefix compilable. Task-number: QTBUG-137566 Change-Id: I285ff866ac057c2997345742515e8d2cf21cec4b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of files under serialization prefixOleksii Zbykovskyi2025-07-255-281/+353
| | | | | | | | Made each file compilable and added them to the build system. Task-number: QTBUG-137566 Change-Id: I3127773b2ca90b52597ac491c49d35f2c295a05e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of files under mimetype and plugin prefix in code folderOleksii Zbykovskyi2025-07-254-50/+74
| | | | | | | | Made these files compileable. Task-number: QTBUG-137566 Change-Id: I68747552d4508ebee1f9fbd62683a3738ef9050f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix files under src_corelib_kernel prefixOleksii Zbykovskyi2025-07-2417-813/+1183
| | | | | | | | Fixed each file and added to the build system. Also updated docs. Task-number: QTBUG-137566 Change-Id: I8e75b9b089167c427bab236c4792fd1056432be9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of files under src_corelib_io prefixOleksii Zbykovskyi2025-07-2416-875/+1139
| | | | | | | | | | | | Made all snippets in these files compilable Also fixed some documentation related to the snippets change. Removed qdebug docs file since it was not used anywhere except one file. Obviously, moved the text to that file. Task-number: QTBUG-137566 Change-Id: I914afc96d58617a04d03d4f6e9545ec1aa2a8eb8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add snippets to the build system and fix related issuesOleksii Zbykovskyi2025-07-245-234/+276
| | | | | | | | | | | | Created CMakeLists.txt file with all compilable snippets by now, and added it to the build system. Also fixed some previous files to make them build correctly. And fixed some documentation related to the snippets change. Task-number: QTBUG-137566 Change-Id: Ibf4321dd243bdf774c508bc1e43f9019a9074c30 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QRM: remove the SingleColumn wrapper typeVolker Hilsheimer2025-07-221-29/+41
| | | | | | | | | | | | | | | | | | | | | | The RowOptions template gives us a better mechanism of declaring a type with metaobject as a multi-role item in a list. The SingleColumn alias of a single-element tuple is not as transparent as it should be, and operating on a list of types wrapped this way becomes quite cumbersome (using std::get<0>, extra braces for initialization). Adjust the documentation to focus on the RowOptions mechanism, and replace relevant test cases with a single-element tuple, which can still be used for situations where specializing RowOptions is not applicable, such as for row types that don't have a meta object. If we see a clearer use case for a wrapper-based solution, then we can try to add a transparent SingleColumn wrapper type for which we specialize row_traits explicitly, without the complexity of the tuple protocol. Pick-to: 6.10 Change-Id: I515d9cb5c5129bd639fa9b20004be9a4101469eb Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QRangeModel: allow gadgets to declare themselves as MultiRole itemsVolker Hilsheimer2025-07-211-6/+58
| | | | | | | | | | | | | | | | | | | | | | | | For Quick, gadgets in a list should be represented as single-column/ multi-role items. Wrapping the gadget type into a SingleColumn is possible, but messy, as it changes how the underlying data structure works. We can in addition allow the gadget type to declare itself directly as a multi-role item: by specializing a QRangeModel::RowOptions template, and giving it specific member types or constexpr values, types can modify how QRangeModel interprets them. This gives us a very flexible and extensible mechanism for future behaviors and compile-time optimizations. For now, check for a rowCategory member value, which can be set to MultiRoleItem to override the default interpretation as a multi-column row. Adjust test and documentation. Pick-to: 6.10 Change-Id: Icd2542ac2a9fb4abe7698bb4341b67053e01aa93 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QRangeModel: remove the need for the MultiColumn wrapperVolker Hilsheimer2025-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | So far, the row_traits specialization has been ambiguous for types that have both a meta object, and are tuple-like. That doesn't have to be so: we can explicitly specialize the traits for each combination, and when both are present, select one of them. Implementing tuple-protocol for a gadget or QObject type is a rather explicit choice, so we interpret such types as tuples. This also gets rid of the make_void helper. Adjust test and documentation. The way that we used pointers to stack- allocated objects in the test was fishy anyway, and we are now always using the table protocol for those models, which deletes the row instances for us. SingleColumns can also be used to represent a range as a value instead of a multi-column item, and to explicitly request a type with meta type to be interpreted as a multi-role item. So we leave it, at least for now, even though it's clumsy to use. Might be best to get rid of it as well and just document that a single-element tuple can be used instead. Pick-to: 6.10 Change-Id: If5abd20e2dd44e793f4de52d778e8d723f1fa584 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QDeadlineTimer: link to cppreference.com for chrono_literalsMarc Mutz2025-07-181-9/+4
| | | | | | | | | | | | | | | | | | | | Also don't use 'using namespace chrono' in snippets, but spell the types (nanoseconds, steady_clock) out in full. That doesn't break line-length limitations and makes it clearer (for the reader, and eventually, qdoc (when QTBUG-138535 lands) where each identifier comes from. Also remove the using namespace std::chrono_literals from the code snippets. They are repetitive and the linked cppreference.com gives all the available options how to import them, not just the one chosen here. Amends 12eacc3bab00f23d187a295b35e4a0d283ba85f4. Pick-to: 6.10 6.9 6.8 6.5 Task-number: QTBUG-138538 Change-Id: Id983c74cae16e98344e09d5575dc9927c76bec77 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix of files under src_corelib_global prefixOleksii Zbykovskyi2025-07-145-470/+735
| | | | | | | | | Small fixes to make files compile. Renamed one of the snippets and changed it in the docs. Also removed repeating snippet. Task-number: QTBUG-137566 Change-Id: I894d1d234661cca09c56b4a8d48e14b7e2f065c0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of snippets under src_corelib_animation prefix plus oneOleksii Zbykovskyi2025-07-115-84/+124
| | | | | | | | | Only small fixes and in qpropertyanimation.cpp, renamed and moved snippets to make them compilable. Also, I renamed them in the doc. Task-number: QTBUG-137566 Change-Id: Ie83f86e88064eec6d6b08f75f7e4757bb569275d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of files in code folder under doc_src_ prefixOleksii Zbykovskyi2025-07-1112-670/+893
| | | | | | | | | | | | | code folder in snippets contains to much files so I decided to commit them by prefix. This commit contains files with doc_src_ prefix. I only fixed some small bugs in each of the files. Also renamed a few snippets to make things easy and more clear. Change-Id: I43bf05e77dc89623b0ad6e4df8baa08768ae8c14 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Disable warnings in snippetsOleksii Zbykovskyi2025-07-115-0/+10
| | | | | | | | | | Set target property in the CMakeLists files of snippets to disable warnings from them. Task-number: QTBUG-137566 Change-Id: I12a2ff1a33c654061c955b562bc58267dc212636 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: rename targets to be more preciseOleksii Zbykovskyi2025-07-104-12/+12
| | | | | | | | | Renamed all new targets by adding the `corelib_` prefix to make it clear that these are snippets in the corelib module. Task-number: QTBUG-137566 Change-Id: I5326b43170e391fe3f0b0a945cb60b322f2fd14b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of overcomplicated snippets usage and related filesOleksii Zbykovskyi2025-07-104-53/+35
| | | | | | | | | Fixed the exception in qsignalmapper with the constructor duplication and relocated and renamed related snippets. Task-number: QTBUG-137566 Change-Id: I21edba82ffb52388fb38d07a35430e497a870175 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Snippets: snippets_qprocess unity buildableTim Blechmann2025-07-051-0/+2
| | | | | | | | | Both files include a definition of main(), so we disable unity builds here. Pick-to: 6.10 Change-Id: I1a96f2c4908bf59080f824c7eaa2aaaccae4da39 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Fix per-repo developer buildJoerg Bornemann2025-06-301-13/+0
| | | | | | | | | | Don't try to find_package(Qt6Qml) in qtbase. This produces a CMake error in a per-repo developer build. In a top-level build, there was no error but qlogging.cpp was still not compiled. Remove the whole block. Change-Id: Ie7266b2f66744379590a7734cabfb95a754d80ea Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix JNI snippet code compile errorsAssam Boudjelthia2025-06-291-1/+9
| | | | | | | | | | Add needed includes and leave out Java code. Amends 6a49c7f19f514056a7029de6ae04b424e5affc5a. Task-number: QTBUG-137566 Change-Id: I0bbefb406be8eca1c079bf1b8c3583a67380d495 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix compile unused and uninitialized compile warnings for qprocess snippetAssam Boudjelthia2025-06-281-1/+3
| | | | | Change-Id: I5c5a8693c16970078941c91a1bceca0ee3edbc09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Create a couple of CMakeLists and fix related cppsOleksii Zbykovskyi2025-06-269-13/+93
| | | | | | | | | | | | Added a banch of CMakeLists to different folders. In the qprocess folder deleted the unused QApplication and added condition for windows. In qstring, fixed some small bugs. In qsignalmapper, added a condition to avoid naming problem Task-number: QTBUG-137566 Change-Id: I63e04cdd01b5854ab5f2dac2a0c317eea35f5b42 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add more snippets sources from corelib to the build systemOleksii Zbykovskyi2025-06-2618-120/+133
| | | | | | | | | | | | | | Trying to compile snippets and fixing some bugs with them. Added some files and targets to CMakeList.txt. Added SOURCES of files that triggers Widgets in CMakeList.txt. Handled "no widgets" and "no qml" cases for snippets compiling. Relocated the necessary header file for qtcast. All others are just small fixes. Update: fixed path to the qlogging snippet in docs Task-number: QTBUG-137566 Change-Id: I6c6068790bf24ca88072cf8ca5c33b1401551452 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QRangeModel: documentation improvementsVolker Hilsheimer2025-06-201-0/+71
| | | | | | | | | | | | | | Some restructuring, and include a section on rows as values vs rows as pointers. That paragraph as written so far was confusing, even for me, and the subject matter is complex enough to require more than a single paragraph anyway. Still work in progress, esp with some pending changes to enforce the requirement that ranges of pointers cannot be passed by value. Pick-to: 6.10 Change-Id: Ie4496ffb32b2622835c3cc4662da129e34e3f8c7 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QRangeModel: fix indentation of snippetsVolker Hilsheimer2025-06-201-136/+134
| | | | | | | | | | qdoc will use the indent level of the //! tag to "normalize" the indentation of the code, so use that instead of using no indentation, which is hard-to-follow. Pick-to: 6.10 Change-Id: I2b273854f3b3549574d549bb2b67ee43023bbb00 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QMultiHash/Doc: document erase() functionThiago Macieira2025-06-191-0/+12
| | | | | | | | | Contents are a duplicate of QHash's. Fixes: QTBUG-137838 Pick-to: 6.10 6.9 6.8 Change-Id: I9abcfeaad630a0b66e6bfffdbb318e826d7a32ef Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* timers.qdoc: cleanup API docs wrt. QChronoTimerAhmad Samir2025-06-192-24/+29
| | | | | | | | | Amends 87030778969165a285af2d919d6d7293e8078b6a. Pick-to: 6.8 6.9 6.10 Fixes: QTBUG-133029 Change-Id: Ida5e0b8075222ec0d5e28d11b375dd1f2976fa1e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonObject/QCborMap: Add asKeyValueRange()Johannes Grunenberg2025-06-181-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds {QJsonObject,QCborMap}::asKeyValueRange() which returns a range over key-value pairs of the object/map (`pair<QAnyStringView, QJsonValueRef>` and `pair<QCborValueConstRef, QCborValue>`). This uses QKeyValueIterator under the hood. QJsonObject's iterator only iterates over the items, so using it in a range-based for loop won't give users access to the key. With `asKeyValueRange` one can iterate over both keys and values and conveniently use structured bindings. QCborMap's iterator already iterates over key-value pairs, so `asKeyValueRange` is provided for API symmetry. In `QKeyValueIterator`, this adds a fourth template parameter `Traits` to support custom `key()` and `value()` functions. This is specifically needed for `QJsonObject`, as its actualy key is a string view, but `key()` returns a `QString`. [ChangeLog][QtCore][QJsonObject] Added asKeyValueRange to iterate with a range-based for loop over key-value pairs with support for structured bindings. [ChangeLog][QtCore][QCborMap] Added asKeyValueRange to iterate with a range-based for loop over key-value pairs with support for structured bindings. Pick-to: 6.10 Change-Id: I68d97fada8b2d7ef7224f1beb5aa685aac3d1b16 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QDebugStateSaver documentation snippetIvan Solovev2025-06-161-0/+1
| | | | | | | | | | | | | Add the actual usage of the class Amends b956fec7eed57713faa5736917661280e5cec16c which was merged into 6.5, so pick down to that branch. Fixes: QTBUG-137579 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I4fc1110ae994c06e17530eb4b227382113a6c811 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* QRangeModel/Doc: link to QtWidgets only if the feature is setThiago Macieira2025-06-121-4/+3
| | | | | | | | | | | | | | | | | | Amends efe41182fda94c0e4805c24b3305577e5da81880. The code already tests for QT_NO_WIDGETS before including and using Widgets APIs, and we will want to extend the corelib_snippets target with more of the existing snippets code to make sure that they build. To not break -no-widgets builds, don't link against Qt::Widgets unless the feature is set. Pick-to: 6.10 Fixes: QTBUG-137556 Change-Id: Ic30fd519416068c275c3fffd0e1df10a76ce8fad Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>