summaryrefslogtreecommitdiff
path: root/src/qml/doc/snippets/qmltc
Commit message (Collapse)AuthorAgeFilesLines
* Remove AUTO_RESOURCE_PREFIX, and refer to QTP0001 when possibleAmir Masoud Abdol2023-02-211-1/+2
| | | | | | | | Pick-to: 6.5 Task-number: QTBUG-96233 Change-Id: I4126760dddc9ec1b5c8850fb30a80730e19cb307 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Allow omitting the version of QML modulesUlf Hermann2023-01-272-2/+1
| | | | | | | | | | | | | | | | | Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is actually a bad default version since it's before all the Qt versions. [ChangeLog][QML] You can now omit the VERSION argument to qt_add_qml_module(). This will automatically generate the highest possible version. Pick-to: 6.5 Task-number: QTBUG-99146 Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltc: generate code into namespacesSami Shalayel2023-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | Generate code into namespaces to avoid clashes between qmltc-generated and user code. Code generated by qmltc will by default be put in the URI_OF_MODULE namespace, and will generate subnamespaces to follow the module hierarchy if URI_OF_MODULE contains dots('.'). Also fix the test to use the new namespaces. [ChangeLog][Qml][qmltc] The type compiler will generate C++-code into a namespace by default. The new default namespace is inferred from the module's URI, where dots are interpreted as separating subnamespaces from each other, e.g., a type in module MyCompany.MyModule.Sub will be generated in the namespace MyCompany::MyModule::Sub. Fixes: QTBUG-109274 Change-Id: I3bfe2697b81e90bb63a079dc44c2810fc9925f97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qmltc: fix handlers for c++-signalsSami Shalayel2022-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow qmltc to generate handlers for c++-defined signals with const parameters by changing the safeguard to avoid type mismatch between slots and signals. First, remove the qOverload in the generated QObject::connect call to be able the connect slots and signals with different types (namely, pass by const references and pass by value should be interchangeable but is not allowed by qOverload). Second, save in QQmlJSMetaParameter when types are passed by pointer. Like this, qqmljsimportvisitor can check if a value type is indeed passed by value or const reference in a C++ signal. The same for reference types that need to be passed by (const and non-const) pointer. Print a message when an type is passed by argument in an incompatible way instead of letting qmltc generate uncompilable code, which makes the compiler print out cryptical messages. Third, add a qqmlcpptypehelpers template that decides if value types should be passed by value or reference, by letting the c++ compiler check if sizeof(T) > 3*sizeof(void*). Fixes: QTBUG-107625 Fixes: QTBUG-107622 Change-Id: I1a00532df591d10f74c1fd00dff5b7fccf40cb22 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | 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. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-071-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-081-0/+3
| | | | | | | | | | | | 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: I72c89a98c42bbc9234d8495e9e503bec81d11037 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Introduce a sane resource path to qt_add_qml_moduleUlf Hermann2022-06-232-1/+3
| | | | | | | | | | | | | | | | | | Since "/qt" is reserved, we can use "/qt/qml" as the default path for user QML modules. [ChangeLog][QtQml] The AUTO_RESOURCE_PREFIX option was added to qt_add_qml_module(). It places your QML modules in the otherwise reserved resource directory /qt/qml. This directory is also added to the default QML import path. By using it you don't have to specify custom import paths anymore. Specifying neither AUTO_RESOURCE_PREFIX nor an explicit RESOURCE_PREFIX will generate a warning now because such QML modules are likely invisible in the resource file system. Fixes: QTBUG-95145 Fixes: QTBUG-103452 Change-Id: Ie27dec5cbf34ea06258d55c659d202cdd61e54b2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-118-392/+16
| | | | | | | | | | | | 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. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove qmltc compilation command in favor of qt_add_qml_module()Andrei Golubev2022-05-311-6/+4
| | | | | | | | | | | | [ChangeLog][CMake] The qmltc compilation functionality provided by qt6_target_compile_qml_to_cpp() is merged into qt6_add_qml_module() command and is available through ENABLE_TYPE_COMPILER argument. The qt6_target_compile_qml_to_cpp() function does nothing and is left only to highlight that users must migrate away from it. Fixes: QTBUG-100215 Change-Id: Ie7d6b82564dff86176194fce35039ba0d93c0977 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* qmltc: Migrate to new object creation/querying mechanismAndrei Golubev2022-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Serves two things: a) Provides faster/more correct object creation model (long-term) b) Eliminates (more of) prototype's code generation (short-term) The whole object querying now works implicitly through the std::array<QObject *> that QQmltcObjectCreationBase provides. The creation logic is still rather recursive with regards to QML base types processing - unfortunately, we cannot simplify this part now as qmltc requires deeper introspection into the imported types (this in turn requires fiddling with QQmlJSTypeReader and QDeferredFactory<QQmlJSScope>::create()) Since we now use the new object creation pattern, prototype/codegenerator no longer needs high-level compilation methods. So replace prototype's code accordingly with qmltccompiler bits. We can also de-duplicate enum and property compilation (aliases are not touched for simplification) from prototype. Methods and bindings have to rely on prototype and QmlIR at present, their compilation is moved more-or-less unchanged Task-number: QTBUG-84368 Change-Id: I584ceb8f2e3c9f3f79530b02d1c88a4f6c2d06c9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove qmltc prototype code (2/N)Andrei Golubev2022-03-081-3/+3
| | | | | | | | | | | - Migrate to the newer output ir classes (with adjustments) - Deduplicate code writer and remove now-unused output helpers from the prototype version - Remove old output ir Change-Id: Ie7fe5e6d47e18477c65af02cabd89a890628442c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Disable failing declarative tests on Android - Part 2Assam Boudjelthia2022-03-021-0/+3
| | | | | | | | | | | | | | | | This allows us to enable testing on declarative for the module as a whole and have some sort of test verification for the mean time, and fix the fails over time. This also disable tests like qdom and qjsscope which are host tests. Pick-to: 6.2 6.3 Task-number: QTBUG-100991 Task-number: QTBUG-99194 Task-number: QTBUG-101005 Task-number: QTBUG-101006 Change-Id: Ie7ae5b8e0ccdf2f55ce3568091d513a073c48417 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_qmltc_examples: Fix a documentation leftover (FILES -> QML_FILES)Andrei Golubev2022-02-181-2/+2
| | | | | | | | Amends 97123dbe6755a787e93797f717f8ebf193352b85 Pick-to: 6.3 Change-Id: I0f13df4abff4ba2f0bb066480a157f6cfbefa3c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmltc_examples: Set visible text to 0 by defaultAndrei Golubev2022-02-161-0/+1
| | | | | | | | This gives slightly nicer initial UI as a result Pick-to: 6.3 Change-Id: I112ed029d3735b7c960b7723d2aef0b6fc8e1777 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Improve the structure of the output generated by qmltcAndrei Golubev2022-01-311-3/+4
| | | | | | | | | | | | | | Make an effort to separate user-visible APIs from internal code relevant to qmltc In the process of doing it, make tst_qmltc_examples::helloWorld() test less brittle by using QMap instead of QHash when dumping C++ member functions of the type. QHash does not guarantee that the keys are ordered while QMap does (via operator "<") Pick-to: 6.3 Change-Id: I1495e1755d3fd77950acb3820ad2b9c5e3cdee33 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Rename CMake command's argument FILES -> QML_FILESAndrei Golubev2022-01-261-1/+1
| | | | | | | | | This way we make it consistent with qt_add_qml_module() Fixes: QTBUG-100214 Pick-to: 6.3 Change-Id: I9f38a8ba3dec978ccdf4ea937ff662ae2449e582 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Document qmltc output formatAndrei Golubev2022-01-264-12/+241
| | | | | | | | | | | | Make understanding qmltc output easier by showing how it works on a trivial example. Add a paragraph on the generated code location as an addition Fixes: QTBUG-100051 Pick-to: 6.3 Change-Id: I0fa0f2c6c60fef7accbe855159275591d9e8bbc6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Document qmltc toolAndrei Golubev2022-01-197-0/+643
Add initial qmltc tool documentation with introduction, compilation process picture, description and limitations To simplify the description, we can consider some simple application. The same app can additionally become a test scenario for qmltc and a showcase of its capabilities Task-number: QTBUG-84368 Pick-to: 6.3 Change-Id: If6d586a8c68f48d17133b25170d0fff627e2066c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>