Commit Graph

220 Commits

Author SHA1 Message Date
Fabian Kosmale 612d988243 Add cmake support for examples
qml-i18n needed to be ported to CMake first. It uses qt_add_translations
introduced in 6.2

As a drive-by, move find_package calls from examples' CML to the top
level CML, and make the QtSql dependency optional. Also make sure that
we only add the dynamicscene example when the Quick target is available.

Pick-to: 6.2 6.3
Fixes: QTBUG-90964
Change-Id: Id357eb14e4704753386e01393300966eb89b4e86
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-29 22:12:43 +02:00
Kai Köhne 9d82f4bff8 Improve examples CMakeLists.txt
- Remove # generated from xyz.pro comment from pro2cmake
- Remove "# special case" markers for pro2cmake
- Remove automatic use of CMAKE_AUTORCC
- Only opt into CMAKE_AUTOUIC if .ui files are involved
- Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR
- Combine multiple find_package(Qt6 ... calls)
 - use REQUIRED COMPONENTS
 - sort components alphabetically
- Fix wrong indentations
- Use (only) one empty line after multi-line commands

Pick-to: 6.3
Change-Id: I0d6bfb06c4b25e9921d3d2bf31d977150f12b31b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-24 13:25:13 +01:00
Ulf Hermann 712b637b58 Rename "Basic Types" to "Value Types"
Internally they've been called "value types" all along. Now that we are
adding the ability to define your own value types the "basic" name is
not really fitting anymore. Value types can be quite complex.

Change-Id: I5fb4abec1dd2f0bbf7fb7f08b02db0882490e983
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 01:23:59 +01:00
Alexandru Croitor 2f45a9c2b9 Switch examples to build as isolated sub-builds
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Change-Id: I7fab73f63a22901ab2d4d4e57b5a25b433100de5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-16 18:28:29 +01:00
Fawzi Mohamed c630ee67b7 qmldom: load and rewrite example
load and rewrite example using the standalone build of the dom and
compiler libraries

Change-Id: Ib7823712aea2164291c21b07956dcec734bc9542
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-07 12:47:34 +02:00
Friedemann Kleint c442ed4d65 Polish the QML reference examples
- Use member initialization, which allows for using
  constructors from the base classes
- Use qsizetype for indexes
- Use qInfo() instead of qWarning() for printing
- Add spaces/fix formatting

Pick-to: 6.2
Change-Id: Iebce1b810ce00f29395207d93303363b3b71e52e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-04 10:51:39 +01:00
Ulf Hermann d7862eac1b Update examples to use new PropertyChanges
Also, prefer the multi-line syntax over ';'-separated bindings for
readability.

Change-Id: I3d6eb854e514ee257ca83773a11e6e9e10770bff
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-11-03 09:14:48 +01:00
Shawn Rutledge 0c4851e12b doc: Replace qmlscene with qml
We deprecated qmlscene in a9c93e2716
so we should stop recommending it in docs, too.

Task-number: QTBUG-53219
Pick-to: 6.2
Change-Id: Ic729624a8ef849bd13f38087e20b5a410c5c5756
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-29 23:16:33 +02:00
Ulf Hermann be260ba529 Fix dynamicscene example to use a QML module
Pick-to: 6.2
Change-Id: I23b87b8ca98721cebc0dc948f0c9bbf741af6cd5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-04 08:48:15 +02:00
Oliver Eftevaag 5d751f3ce6 Simplify the XmlHttpRequest example
The XmlHttpRequest example contains a lot of unnecessary code, and I
felt that most of it could just be removed.

The point of the example project is to showcase how to use the
XMLHttpRequest javascript object to make requests.

Which is why I felt that we could remove any outside dependencies for
the project (like the LauncherList from the 'quick/shared' directory),
and reduce the amount of components down to the minimum.

Fixes: QTBUG-95734
Pick-to: 6.2
Change-Id: I9b062f4d7e942db4a2669a8c65f7488aa4a54740
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-09-03 10:39:37 +02:00
Alexandru Croitor 9cbf4d2cc8 CMake: qmake: Fix chapter6-plugins example to build in more configs
Before this change, I tested the following configurations / scenarios

 (1) shared Qt + qmake + macOS bundle -> works
 (2) shared Qt + CMake + macOS bundle -> broken
 (3) static Qt + qmake + macOS bundle -> broken
 (4) static Qt + CMake + macOS bundle -> works

 (2) was broken because the shared qml plugin is not located in the
 expected location (see below)
 (3) was broken because qmake needs a lot of error-prone boilerplate
 to ensure static qml plugin building and linking works.

The change fixes the example to build and run successfully in case
(2).

Tested the following scenarios on macOS with the change

  shared Qt + qmake + macOS bundle -> works
  shared Qt + CMake + macOS bundle -> works
  shared Qt + qmake + no bundle    -> works
  shared Qt + CMake + no bundle    -> works
  static Qt + qmake                -> still broken
  static Qt + CMake                -> works

To make shared qml plugins be found in a macOS bundle, we need to copy
the qmldir and plugin under the bundle's PlugIns subfolder, because
the application adds that as the expected qml import path for macOS.
This basically mimics what the qmake project does with
QMAKE_BUNDLE_DATA.

The change also cleans up the CMake projects a bit so they don't link
PUBLIC-ly against dependencies, install the plugin under a more
sensible location and don't needlessly setup package finding and other
boilerplate that's done in the parent project.

The change also cleans up the qmake projects to adjust to not pollute
the macos bundle dir with static plugin files.

Amends 9e1d2a0eb1

Pick-to: 6.2
Change-Id: I45bb699a67adf598587350a03f778291fad3f850
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-31 14:51:25 +10:00
Craig Scott 784af37650 Fix warnings/errors from changes to paths in chapter6-plugins example
Amends 2d2750efc3b5a97a5f1cf09b4265a26fcc393499

Change-Id: Iab27efb7359cfcea9274dcbbc7ac64b647d3e71b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-31 14:51:22 +10:00
Oliver Eftevaag dad9a15c9c Replace custom button component with QQC2 buttons
Now that we've moved qtquickcontrols2 into the qtdeclarative submodule.
We want our examples to simply use qqc2 controls, rather than custom
made buttons and other controls.

This example used a custom made button component, which this patch will
replace with qqc2.

It will also use qqc2 in other places where it makes sense, like replacing
a TextEdit with a qqc2 TextArea, and Text components with qqc2 Labels.

Task-number: QTBUG-95733
Pick-to: 6.2
Change-Id: Ic733cd592cd10ef2cf45058aaf08a0f6b2f5bd2c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:48 +02:00
Craig Scott 9e1d2a0eb1 Update qml examples for improved target path handling
Some examples were still using the old "add as ordinary resources"
approach for QML modules, others needed adjustment to the subdirectory
structure to better reflect the URI structure of the QML modules
involved.

Task-number: QTBUG-95144
Pick-to: 6.2
Change-Id: Ie3399410cf6df491eb1e7b4a589ca26c577d82a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:08:21 +10:00
Joerg Bornemann b4ab58d791 Raise cmake_minimum_required to VERSION 3.16 in examples
Pick-to: 6.2
Task-number: QTBUG-95636
Change-Id: I9f76b787533dad1c469fbb8c69df6c27b20a9aa3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 13:48:14 +02:00
Craig Scott 0c99c17761 CMake: Change the default of OUTPUT_DIRECTORY for qt6_add_qml_module()
The new default is now controlled via a new QT_QML_OUTPUT_DIRECTORY
variable. If that isn't set, the fallback assumes the source directory
structure follows the URI structure and uses
${CMAKE_CURRENT_BINARY_DIR} instead. This pattern means more projects
will have working import paths for qmllint and possibly other tools
out of the box. There should also be fewer cases where the
OUTPUT_DIRECTORY option needs to be used in calls to
qt6_add_qml_module(). The QT_QML_OUTPUT_DIRECTORY variable facilitates
the scenario where QML modules might be distributed across different
parts of the source directory hierarchy, but once collected under a
common base point defined by QT_QML_OUTPUT_DIRECTORY, they form a
coherent set of QML modules whose subdirectory structure below that
base point follows their TARGET_PATH.

Fixes: QTBUG-94164
Fixes: QTBUG-95081
Pick-to: 6.2
Change-Id: I82864c361a2b34f7f1484cdbda0d9b64b34b9950
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-20 16:33:48 +10:00
Ulf Hermann 213b890899 Add missing "override" keywords
Our examples should follow best practices.

Change-Id: Ice90a818ae46e921b421e8d297806d8f7200294b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:17:01 +02:00
Ulf Hermann b200fbe213 Do not call QGuiApplication::exec() on an instance
It's a static method. It should be called statically.

Change-Id: I15fc8948988b0a2c0a30f8699949e06c66d92fdf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:16:55 +02:00
Ulf Hermann 1629fa0c6c Use nullptr rather than 0 for null pointers
Change-Id: I2921298ad2e04001bdee8824c56f01c203efb7d6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-06-30 14:16:49 +02:00
Craig Scott 1c4ba17015 Refactor and update qml CMake API
The existing CMake API for qml modules had a number of
shortcomings. Refactor it to achieve the following:

- Clearly separate public and internal aspects.
- Re-use code from qtbase for adding plugins and module
  targets rather than reimplementing close variations.
- Provide more robust and complete support for qmllint,
  qmlcachegen and automatic generation of qmldir files.
- Reduce the steps needed for more common scenarios.
- Encourage the use of separate backing library and plugin
  targets.
- Automatically generate the plugin class .cpp file where
  possible.
- Specify .qml files directly through qml-specific API
  elements rather than assuming they can be extracted
  out of a set of resources.

[ChangeLog][QtQml] The qml CMake API has changed from 6.1
and is now out of Technical Preview status. The most
notable change is that .qml files should no longer be
specified as resources, there is dedicated handling for
them in the qt6_add_qml_module(). A related change is
that the qt6_target_qml_files() command has been replaced
by qt6_target_qml_sources(). More complete integration
with qmlcachegen, qmllint and qmldir generation is also
part of the CMake API.

Fixes: QTBUG-91621
Task-number: QTBUG-82598
Task-number: QTBUG-88763
Task-number: QTBUG-89274
Task-number: QTBUG-91444
Change-Id: I25aae1b0e89890394dfe2ba2824008164b2ca8d9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-06-04 16:54:52 +10:00
Craig Scott 2422dd5a7a Switch examples to build as isolated sub-builds
Task-number: QTBUG-90820
Change-Id: Id9157526898ba72cb64ee8256639b37357f7bacf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-05-27 21:08:14 +10:00
Joerg Bornemann 1917a868d9 Use fixed qt_add_resource BASE argument
Pick-to: 6.1
Task-number: QTBUG-86726
Change-Id: If6e1033642d98ccd40daeb57a453c0e5bc2985da
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-21 00:21:26 +02:00
Maximilian Goldstein 3168111285 examples/qml/locale: Use inline component as a delegate
Modernize the code by using an inline component as a delegate in this example file instead of declaring the delegate inline.

Change-Id: I52c75f81c42362f858f63bdbbaf432c0966309fe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-05-19 11:46:37 +02:00
Ulf Hermann 4cc91a6a0e Use functions as signal handlers when accessing parameters
Injected signal handlers are bad practice because they aren't declared.

Pick-to: 6.1
Task-number: QTBUG-89943
Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-12 10:30:20 +00:00
Maximilian Goldstein 56f428c360 qmlfunctions.qdoc: Add clarification to QML_FOREIGN
Fixes: QTBUG-87150
Pick-to: 5.15 6.0
Change-Id: If99a06a07892bdfef7b6b1e8fa737480750992fe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-23 14:29:02 +01:00
Ulf Hermann d7008c79d4 QQmlListProperty: Use qsizetype rather than int for sizes
[ChangeLog][QtQml] The QQmlListProperty callback functions use qsizetype
now as type for the size of a list. This is in line with the containers
that you might use to back the list.

Fixes: QTBUG-88269
Change-Id: Ia38403cb32f241e6c70e1a580dbeff1d6d694331
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-09 18:09:30 +01:00
Alexandru Croitor 20d5e2d7ef CMake: Regenerate examples to set the WIN32_EXECUTABLE property
As well as the MACOSX_BUNDLE properties as necessary.

Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: I46769fb543acb2cbeba122470b5e44ad478fbe4e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 23:38:39 +01:00
Alexandru Croitor 903252b240 CMake: Regenerate examples to use qt_add_executable
Task-number: QTBUG-87661
Change-Id: Ie5bba408000211b24694aa0143bdf79c4a298f42
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2020-10-20 09:32:34 +02:00
Ulf Hermann e7d90fc526 Fix lineedit example
The default name created by QML_ELEMENT is the name of the local type,
not the one of the foreign type.

Pick-to: 5.15
Task-number: QTBUG-87150
Change-Id: I2b5dfcea3e835d4e69d5fa4df179333a37ee1d6e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-05 12:56:37 +00:00
Tor Arne Vestbø d0eb261836 Remove use of deprecated High-DPI application attributes
Change-Id: Ibfb50fdcbb51ba93d6e5d11f9e8ce0e7b3bfde79
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-09-02 17:17:33 +02:00
Edward Welbourne 572882fd67 Example: Pass QDate, QTime by value, not by const reference
They're value types, packaging qint64 and int, repsectively.

Change-Id: Icf18794466cd140e1384d6dd0de736fbb2c05a48
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-09-01 16:57:01 +02:00
Sze Howe Koh 024ec9c564 Doc: Fix minor typos
Pick-to: 5.15
Change-Id: I4c51c40697e410d56b6a2d2446ed9f8ae218576d
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2020-08-30 09:59:49 +08:00
Jarek Kobus dd71c43b97 Use QList instead of QVector
Task-number: QTBUG-84469
Change-Id: I4c3353c00a566023503fbc178ba8454391dc334c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-25 07:54:07 +02:00
Kai Koehne 1f0b3a54ff Examples: Fix double installation of .qml files
qt_example_installs.prf already generates install rules for all example
sources, including content of .qrc files.

Pick-to: 5.15
Fixes: QTBUG-84301
Change-Id: I3454b19849af489c5819c51867781cc97f1eb285
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-02 14:44:26 +02:00
Alexandru Croitor a7c7e7ceaa CMake: Don't install .qmltypes for Qt tests, examples and tools
that don't have an explicit QT_QML_MODULE_INSTALL_DIR path
specified. We don't want to pollute the Qt qml import path with
these files.

Task-number: QTBUG-84403
Change-Id: I768267e0e79daa8090d882c301648cce14e1a809
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-29 10:01:40 +02:00
Alexandru Croitor 965984771d CMake: Regenerate qtdeclarative/examples
Includes
- new example installation paths
- one case of QT_QMLTYPES_FILENAME addition

Change-Id: I24423da9b04b6ecc8445017fa35f148dd43b1829
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-05-29 10:01:22 +02:00
Alexandru Croitor 26c5243491 Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
	dependencies.yaml
	src/qml/qml/qqmlengine.cpp

Change-Id: I6a73fd1064286f4a2232de85c2ce7f80452d4641
2020-03-12 15:03:03 +01:00
Olivier Goffart f3dccc334f Adapt to the the new QMetaType change
Fixes: QTBUG-82453
Change-Id: I7e5682945a07c3af183becd3947a69568f139d16
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-09 10:54:37 +01:00
Assam Boudjelthia 069afedec9 Examples: add .pro project for qml-i18n example
Currently only the .qmlproject is available for this project, which
won't deploy on Android, thus adding .pro project files. Also, since
the translation won't work without the *.qm files being present as
resources, those files are included by default with example.

Task-number: QTBUG-80717
Change-Id: I86ac6c4097e4207b7f62d628f9a72439e78639db
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-05 11:18:50 +02:00
Assam Boudjelthia 1fef24732b Examples: Add *.pro projects for existing *.qmlproject
The *.qmlproject won't deploy and run on Android, thus adding
normal .pro projects to allow deploying to Android.

Task-number: QTBUG-80717
Change-Id: I8a79a56bec57add315c08088a2fca5995df76912
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-04 12:13:06 +02:00
Ulf Hermann 8ccc86d319 Doc: Update documentation for "extending" example
It referred to qmlRegisterType() even though we don't call it anymore.

Change-Id: Ib07e4428d032e789d705156ddc4c9589fd797c65
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-19 11:26:05 +01:00
Ulf Hermann 8bc51b89a1 Doc: Fix extension plugin examples and documentation
We advertise the usage of QQmlEngineExtensionPlugin, as registerTypes()
should be avoided if possible. The actual source code of the examples
already does this, but some of the includes and the documentation was
lagging.

Task-number: QTBUG-81615
Change-Id: Ibbee60ad55114bf6dc07875080c963e727f49e6b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2020-02-18 09:45:16 +01:00
Ulf Hermann 90b4528b84 Avoid discouraged patterns in examples
In particular, use required properties where applicable, explicitly
import QtQml where we use it, avoid unqualified access into the root
scope of a component, use JavaScript functions with explicit parameters
as signal handlers.

Change-Id: I3eaaba47cc3c7a2a12d488e36f9eec145cedbb0e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-02-11 19:26:05 +01:00
Ulf Hermann 38c0370923 Doc: Fix "Extending QML" documentation
It mentioned qmlRegisterType where that didn't exist anymore.

Change-Id: If3e8c8ada746c720bff216df8c5f3fb618e09205
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-11 19:25:53 +01:00
Ulf Hermann 6d0a453f41 Use the extended QQmlListProperty interface in a few places
Task-number: QTBUG-79263
Change-Id: If518f644b5b9eddbacfb1cb16fbb557127ffcfb2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-02-07 09:37:53 +01:00
Alexandru Croitor 97a5cf8634 Regenerate examples
Change-Id: I39564d4b644a7ee367d9ce92b85426a5c2a122a4
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-29 15:39:22 +00:00
Leander Beernaert 7c229d3cf8 Post merge fixes
Change-Id: Ie8aca222809f35174fb6c6488832ec3ff5432272
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-01-24 12:30:00 +00:00
Leander Beernaert 1d333d3375 Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I0c5b939c70bdb91ccdf7068784308416dcaa5736
2020-01-16 16:25:06 +01:00
Ulf Hermann da4cdfec98 examples: Make qmlextensionplugins example usable without installation
The qmldir file as well as the .qml files have to be placed next to the
plugin, the import path has to be added to the .qmlproject, we want the
.qmltypes file added to the same place, and the plugins.qml should also
be available in the destination directory.

Change-Id: I82b369693e612779c6213345cc8f6a30b16d41b4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-14 09:44:15 +01:00
Ulf Hermann 2c3419e127 Generate registrations for all examples
Now that we can generate all QML type information at build time, we
should also use it.

Change-Id: I647c72bbe38fdb2deb565b75c86a696af3d15b61
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-13 16:47:57 +01:00
Fabian Kosmale 4eff729950 Binding example: Fix type registration
Fixes: QTBUG-81335
Change-Id: Ie93c9b7ad49703bce245592e659ccdb6ea2b7ed9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-13 13:27:36 +01:00
Leander Beernaert f1f395b37d Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I48b9c2e4f3a75c18470c55f73f2089dc1401de54
2019-11-25 15:34:40 +01:00
Ulf Hermann 0a649f2581 Fix xmlhttprequest example
The "pressed" property belongs to mouseArea, not button.

Change-Id: Ib35c520b75e30c2cb9a3a7dee0b482a2209040c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-14 10:09:36 +01:00
Alexandru Croitor c2f8b9535d Merge remote-tracking branch 'origin/dev' into wip/cmake
Removed dependencies.yaml because we don't use it yet in wip/cmake.
Fixed conflict in qmlcachegen.cpp.

Change-Id: Ie1060c737bee1daa85779903598e5b6d5020d922
2019-10-14 19:02:37 +02:00
Leander Beernaert 9e633bbda7 Regenerate Examples
Change-Id: I2fbfb44bbb6d667e022bffb480feaf74ff0d0a5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-14 09:09:55 +00:00
Alexandru Croitor 6a0bb9a7d6 Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I4a91928610f79c8e21a05781953ffa41508c828a
2019-10-11 16:21:42 +02:00
Ulf Hermann cc1a604c70 Specify parameters of type registration in class declarations
Using this technique we can automatically register all necessary
revisions and minor versions of a type, using the metaobject system.
This greatly reduces the potential for mistakes and resulting
incompatibilities between versions of imports.

We assume that for each type we need to register all revisions of its
super types and its attached type, and that the revisions match. That
is, if you import version X of type A, you will also get version X of
its attached type and of any super types. As we previously didn't take
these dependencies into account when manually registering the types, a
number of extra revisions are now registered for some types.

Potentially, we can now generate the qmltypes files at compile time,
using moc.

Change-Id: I7abb8a5c39f5e63ad1a0cb41a783f2c91909491b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-26 12:32:17 +02:00
Leander Beernaert bf58a1cc04 Update Examples with lowercase qt6_add_resources()
Re-run pro2cmake on all exampls.

Change-Id: Iafd1092beff023b407a8f29c2a5b651f2e534b75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-20 08:38:06 +00:00
Leander Beernaert eff8affd8e Add missing Examples with qml plugins
Add missing example projects which depended on the public QML plugin
API.

Change-Id: I05ed91e74eeaf6644700db13c3083fd110d96a62
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-19 11:37:27 +00:00
Leander Beernaert ec57196980 Add qt6_add_qml_module() public API
Add qt6_add_qml_module() as a public API for building QML modules.

Since the shared implementation details are small, it was easier
to just reimplement the shared code than to unmangle the more
complicated version we use to build Qt from QtBuild.

This patch includes an example conversion. Changes for pro2cmake
will follow in a separate patch in qtbase.

Change-Id: I942526cc7d978e2d8309b506e785f9c1509d0bbc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-19 08:06:24 +00:00
Ulf Hermann d045cd4330 Reference Examples: Fix calls to exec() and exit codes
exec() is a static member of QCoreApplication and should be called as
such. In case of errors we should return a non-0 exit code from main().

Change-Id: I0fefa006841b367d06a9de1fd1284cb7caf467bd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-30 17:57:38 +02:00
Ulf Hermann 76282f480e Use qmlRegisterAnonymousType in examples and tests
Change-Id: I511d18ad8f73ea77a208e4448a8f86e5be5facc3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-27 16:20:55 +02:00
Leander Beernaert b938edcfb3 Convert Examples
This patch converts all examples in qtdeclarative except for a few
exceptions which require a public facing qml plugin api.

Change-Id: I2cd2b1bb455be8b48796893a8235dea7f8b35aa2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-23 13:51:06 +00:00
Ulf Hermann a2e1025354 Reference Examples: Avoid static_cast on function arguments
qobject_cast is safer and not very expensive here.

Change-Id: Ie87219e2a5092e453d257064a95a790de31015f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-20 08:43:01 +02:00
Ulf Hermann adcb79025a Reference Examples: Use override for overridden virtual functions
Change-Id: I9f4225bf312856d08fd08431353f3cb36d0f7fa5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-20 08:42:49 +02:00
Ulf Hermann 3cc226ffe7 Reference Examples: Use nullptr
Change-Id: I325cfdcf488e9d238e618ca23ef40aedf7c5eec1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-20 08:42:30 +02:00
Ulf Hermann 66fabff253 Reference Examples: Use auto for results of new and component.create()
Change-Id: Ibfd92fbc5a99b38cf8b31a11c0adfdfa69e2bb36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-20 08:42:16 +02:00
Ulf Hermann 73a9c52fed Reference Examples: Use initializer lists to avoid repeating type naems
Change-Id: Iff0b31d9b641a55ea246235ba1d7a066592ef0c0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-20 08:42:01 +02:00
Alexandru Croitor 13374ceb16 Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I2963c1209316fb6755f572969f368970450d7991
2019-07-11 17:24:39 +02:00
Marc Mutz 11344a9070 Port from QLineEdit::getTextMargins() to textMargins()
getTextMargins() will be deprecated soon.

Change-Id: I328f87553585fd1450c85191422013ebc0c8f7f8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-07-03 13:29:47 +00:00
Alexandru Croitor 6c69a6ab7c Initial CMake port
Crude port of QtQml, QtQmlModels, QtQuick and a few tests and a few
examples.

Task-number: QTBUG-74136
Change-Id: I5de4d8215b33d1a4a72c2c0e7951e4b384f27e3e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-03 11:03:46 +00:00
Kai Koehne 369998639b i18n examples: Add en translation dummies
We endorse using QTranslator::install(const QLocale&...), because
it tries loading translations from all QLocale::uiLanguages() instead
of the commonly used QLocale::system().name() setup.

Anyhow, the first method requires an English translation - otherwise
a second favorite language might be used.

Pave the way to making the switch by adding (empty) English translations
to our examples.

Task-number: QTBUG-69196
Change-Id: Ie85be875e34e29e80c1693bbf477b962e35a7d87
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2018-07-17 08:55:11 +00:00
Kai Koehne 33a9fb9f4b i18n examples: Update .ts files
Change-Id: I3c1987bac8251b087fab98d6caaaba267dcc4be8
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-07-17 08:55:06 +00:00
Paul Wicking ed3a93feee Doc: Add missing dots (qtdeclarative)
Task-number: QTBUG-68933
Change-Id: Ibb5aa227e82825085e7214e17dcffcb17fd44157
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2018-06-19 12:44:48 +00:00
Mårten Nordheim 44e398f64e Clarify ownership around QQmlEngine::setNAMF
We were leaking an instance of MyNetworkAccessManagerFactory in the
"NetworkAccessManagerFactory"-example. To add to this the documentation
around QQmlEngine::setNetworkAccessManagerFactory did not specify
whether or not it took ownership, causing confusion.

Change-Id: Ic9eee2c45682c752bcb4aa98943fc0af2b630795
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-04-26 19:55:13 +00:00
J-P Nurmi d2ed475b84 Examples: remove bogus return
Change-Id: I653974c80c6767d9af95b9157a73c09dbdeb76cc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-04-03 12:36:21 +00:00
Shawn Rutledge e17c89f4ce use the override keyword consistently and correctly (clang-tidy)
Change-Id: If9e28d143f8cba3df3c757476b4f2265e2eb8b2a
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-02-27 08:27:38 +00:00
Shawn Rutledge 499ec43937 use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.

Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).

Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-26 07:13:18 +00:00
Kai Koehne 341a04377b Fix outdated FDL license header
Change-Id: I76dccf547de40b5e72fd7abaa062fa96cb2c118a
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2017-10-17 11:18:21 +00:00
Kai Koehne ea6cd0de3c Fix outdated BSD license header
Change-Id: Icc08925454445fc9497fb3bfd2c26efe90605983
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2017-10-17 11:18:11 +00:00
Topi Reinio 2baea9d0c3 Doc: Fix capitalization in section titles
...and fix some section titles to be less confusing.

Change-Id: If83c3faffead9e2e9be7fc0fb360f1c5b8b1bb51
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
2017-08-29 09:54:41 +00:00
Friedemann Kleint 85bb44539a Fix GCC 7 warnings in examples
plugin.cpp: In member function 'virtual void MinuteTimer::timerEvent(QTimerEvent*)':
plugin.cpp:85:28: warning: ignoring return value of 'QTime QTime::addSecs(int) const', declared with attribute nodiscard [-Wunused-result]
             time.addSecs(60);

main.cpp: In function 'int qMain(int, char**)':
main.cpp:71:1: warning: no return statement in function returning non-void [-Wreturn-type]

Task-number: QTBUG-60630
Change-Id: I0c0002533aa28c480a4d9eb45856dd10753d2476
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2017-06-21 06:13:32 +00:00
Nico Vertriest b63c210f5a Doc: make screen xmlhttprequest compatible with Designer
Change-Id: Ieaf45a817d4568bd2cd7c3cbbfee62435c2e2594
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-05-03 12:06:29 +00:00
Simon Hausmann 7f32589663 Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qqmltypecompiler_p.h
	src/qml/qml/qqmltypeloader.cpp
	src/qml/qml/qqmltypeloader_p.h

Change-Id: I4894555ab7a0879b56bbda7a46d16d1c40c19e7c
2017-03-15 10:44:33 +01:00
Nico Vertriest 46468c4762 Doc: added snippets to Extension Objects Example
Change-Id: Icbd2393d4b8523e24328f765e76869c86afb3e72
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-03-13 11:40:25 +00:00
Michael Winkelmann a54f08e1ea Replace QList<Person*> with QVector<Person*> and function pointers
The usage of the QQmlListProperty QList constructor is discouraged since
QList violates QML's memory management rules.
Replaced the QList with a QVector and passed the function pointers to the
QQmlListProperty constructor instead, as officially recommended.

Change-Id: I6d28a43530cc3edd5e7d89c351bad70deb721689
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-07 07:11:44 +00:00
Nico Vertriest a0ed2b0ef3 Doc: added specs to Extending QML - Methods Example
Change-Id: I7386c2bd738776455a71bde8cffdcedb9e292b24
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-01-09 09:38:14 +00:00
Nico Vertriest 27ea28b0f4 Doc: Rearranged order of Extending QML Examples
Rearranged in logical order of example build up

Change-Id: I6af8e39bd900d4ce058de46e0b3ebd5e368222c8
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-01-09 09:38:01 +00:00
Nico Vertriest 0f911e46c5 Doc: minor grammar mistake
Change-Id: If3aebd27e886181ebe0d41532935afdfb974586c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2016-12-21 13:17:23 +00:00
Lars Knoll e579076bb3 Get rid of most QT_NO_FOO usages
Instead use QT_CONFIG(foo). This change actually detected a few
mis-spelled macros and invalid usages.

Change-Id: I06ac327098dd1a458e6bc379d637b8e2dac52f85
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-11-29 10:10:27 +00:00
Lars Knoll 4ee2bc4e9c Turn the no-network support into a configurable feature
Change-Id: Ic70f60c124fe166b37fbe9b853735be3c5e0d46d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-10-10 14:11:47 +00:00
Edward Welbourne 74f0d15e08 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/quick/items/qquickshadereffect.cpp
5.7 had a bug-fix in code dev has replaced wholesale.

	src/quick/items/qquickwindow.cpp
	src/quick/items/qquickwindow_p.h
One side changed a method's signature; the other side renamed a method
declared adjacent to it and changed some code using it, moving some
from the public class to its private partner.

	tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
One side added a blank line before a comment the other re-wrote.
Kept the re-write, killed the stray blank.

	.qmake.conf
Ignore 5.7's change to MODULE_VERSION.

	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qqmlpropertyvalidator.cpp
5.7 changed code in the former that dev moved to the latter.
Reflect 5.7's changes there, adapted to dev's form.

	src/qml/qml/qqmlobjectcreator.cpp
One side added new QVariant types; the other changed how it handled
each type of QVariant (without git seeing any conflict); adapted the
new stanzas to work the same as the transformed ones.

	tests/manual/v4/test262
dev had a broken sha1 for it; so used 5.7's 9741ac4655808ac46c127e3d1d8ba3d27ada618e

Change-Id: I1fbe2255b97d6ef405cdd1d0cea7fab8dc351d6f
2016-08-02 18:34:30 +02:00
Edward Welbourne c8c1d4964b PieChart examples: initialize members
Coverity (CID 161680, 161678) pointed out that constructors don't
initialize some members; getters would have returned drivel if called
before setters.  Unimportant but we should set a good example in our
example code.

Change-Id: Ia0483cfbe2cae379a0e84f10db1d8edc9cb5c52b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-07-15 08:22:01 +00:00
Liang Qi 8ae479a8ea Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/qml/jsruntime/qv4engine_p.h
	src/qml/jsruntime/qv4runtime_p.h
	src/qml/qml/qqmldelayedcallqueue.cpp
	src/qml/qml/qqmlvaluetypewrapper.cpp
	src/qml/qml/qqmlvmemetaobject.cpp
	src/qml/qml/v8/qv8engine_p.h
	tests/auto/quick/qquicktext/tst_qquicktext.cpp

Change-Id: I3f0608c7beb88088cbbef4d0db59920f56deaea9
2016-05-24 14:00:39 +02:00
Liang Qi ae745746a6 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/qml/jsapi/qjsengine.cpp
	src/qml/qml/qqmlengine_p.h
	src/quick/items/qquickanchors.cpp
	src/quick/items/qquickanimatedimage_p_p.h
	src/quick/items/qquickitem_p.h
	tests/auto/qml/qqmlecmascript/testtypes.h
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
	tests/benchmarks/qml/creation/tst_creation.cpp

Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
2016-05-13 08:28:27 +02:00
Oswald Buddenhagen ee874f7e0a actually build and install the qml tutorials
Change-Id: Idf81981140e210b29239e91ff5b6b7c40e2f36de
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-05-13 04:35:27 +00:00
Oswald Buddenhagen e6581ed818 fix example installs
Change-Id: Ie6a219392a48fd6b1a32037cc215dc20d408e819
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-05-13 04:35:24 +00:00
Oswald Buddenhagen 578d271719 make use of COPIES
Change-Id: I479c9523a89be1d64364e8205daa5860e16882cc
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-05-13 04:35:22 +00:00
Topi Reinio 35e2f29cde QML extensions tutorial: Add import plugin to app. bundle on OS X
The application in chapter 6 of this tutorial failed to import
the custom extension plugin on OS X, as it could not see it's
import path outside the application bundle.

Change-Id: Icdca1f0553020e0460e4efabc5461a3447b32086
Task-number: QTBUG-47003
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-04-16 02:25:23 +00:00
Sebastian Lösch 392c7b9934 Instantiate static Qml plugins declaring QQmlExtensionInterface only
When instantiating static plugins no check is done whether the
QQmlExtensionInterface is declared. Therefore all user plugins are
instantiated in the Qml thread, which may cause problems.

Task-number: QTBUG-52012
Change-Id: Ia91ec5ec7b2a9721bd11e3648cdc161855b4454e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-04-11 14:10:54 +00:00