Commit Graph

815 Commits

Author SHA1 Message Date
Ulf Hermann cb9cc7ca66 Update views example to use modules
The qmake and qmlproject files are adapted to use the "shared" module,
too.

Pick-to: 6.2
Change-Id: I5fc4895416357ba202528b155581b1b5a880a68d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-30 20:34:49 +02:00
Ulf Hermann 7b6eea37ae Fix the qtquick/window example to use QML modules
The shared code becomes its own module. Due to the ${PROJECT_NAME} trick
it should be possible to include it multiple times, in different
examples.

Pick-to: 6.2
Change-Id: I78cc3211f67fae9a713320fae4041898e6a397ed
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2021-08-30 20:34:43 +02:00
Oliver Eftevaag 621e583f05 Fix coding style
Pick-to: 6.2
Change-Id: Icfcdcb306dbeb750c8ebad44b431c5364ef63c44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-30 15:01:16 +02:00
Oliver Eftevaag 9e38f4da96 ShaderEffects example: replace custom slider with qqc2
Replacing a custom made slider component with a qqc2 slider.

Task-number: QTBUG-95738
Pick-to: 6.2
Change-Id: I407307a3769a0c9821d311189ed40b0d48dab4d3
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-28 17:25:28 +02:00
Oliver Eftevaag 5ae40afa97 Shapes example: use qqc2 components
Changing the example to use qt quick controls where it makes sense

Task-number: QTBUG-95739
Pick-to: 6.2
Change-Id: Id0df227657693234de4481c2316dc6c3e0545043
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-28 17:25:03 +02:00
Ulf Hermann 9cb0b528e3 Update the accessibility example to use QML modules
Pick-to: 6.2
Change-Id: Iec3dad42dd08ac230ffde15b422ae7f68d419e81
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-08-27 17:09:50 +02:00
Oliver Eftevaag e771c12ae7 ImageElements example: Use QQC2 and update copyright
Updating the example to use qt quick controls 2 where it makes sense, as
well as copyright headers.

Task-number: QTBUG-95737
Pick-to: 6.2
Change-Id: Ie22ab8551926916abd0a478adc16d1d4daeb13ad
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:49 +02:00
Oliver Eftevaag 8976c46f46 ExternalDragAndDrop example: Use controls from Qt Quick Controls 2
This patch changes the external drag and drop example to use qqc2
checkboxes instead of a custom made component.

It also changes the position of the checkbox in order to avoid having
the label text overlap with it.

Task-number: QTBUG-95736
Pick-to: 6.2
Change-Id: If3e798ea0ccd64921138690c7599876ec0584038
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:48 +02:00
Oliver Eftevaag 409019bc11 EmbeddedInWidgets example: Use QQC2 components
Replaces the TextBox custom component with a qt quick controls 2
TextField.

Task-number: QTBUG-95735
Pick-to: 6.2
Change-Id: Ic1fb47c8e57cd2d805d4a9941df9bc02a5e7bc17
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-27 17:09:47 +02:00
Laszlo Agocs 266b93c9f8 Use add_shaders with CMake in some examples
Take the most obvious candidates, to which users typically turn
when getting started with ShaderEffect or QSGMaterial:

shadereffects
scenegraph/custommaterial
scenegraph/twotextureproviders

As with the parent patch that ports and updates embeddedinwidgets and
quickwidget/qquickviewcomparison to use the proper CMake machinery, we
still need to keep the .qsb files for the sake of qmake. compile.bat and
similar scripts are however removed now. With CMake the .qsb files are
not needed and are autogenerated at build time. Once qmake support
disappears from the examples, the .qsb files can be removed as well.

Pick-to: 6.2
Change-Id: I879354eef2e2179dcd268c9ae9f1402e1eaef379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 13:51:52 +02:00
Laszlo Agocs c7093e553c Port leftover effects in some of the examples
For qmake we have no choice but to ship the .qsb files, whereas with
CMake we now rely on qt6_add_shaders.

Pick-to: 6.2
Change-Id: I9bb64a3ffd01cda84fca5a0f7def270975bf71aa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 13:51:52 +02:00
Craig Scott a86fd709dd Update quick examples to new QML CMake API
This is a pre-requisite to being able to make
qt6_qml_type_registration() an internal rather than public command.
Not all examples have been updated, only those that were using the
qt6_qml_type_registration() command.

Task-number: QTBUG-95093
Pick-to: 6.2
Change-Id: I3f1814a29af608461daa90477eca0aa2304eb9d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:08:21 +10:00
Shawn Rutledge ca89437d00 Use qEnvironmentVariableIntValue() instead of qgetenv().toInt()
The docs tell us that it's faster.

Pick-to: 6.2
Change-Id: Ib828ed9a10bbb617670a61e7525cbbe25704815d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-17 16:14:53 +02: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 fff8d6120a Use "= default" rather than empty bodies for ctors and dtors
Change-Id: Idef0ebaa0074e1e4b6b74d20bd6c70cb22a04f93
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-07-01 08:34:58 +02:00
Ulf Hermann 91e7009aec Use "auto" as type when initializing using "new"
The type is immediately visible from the right hand side then.

Change-Id: Ifc1a15e3eea9b5a91ff8647f759d207a0ee221b8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-01 08:34:54 +02:00
Ulf Hermann 83859221c1 Initialize members in declaration rather than ctor
Change-Id: I084a6865ae37c6612fbcfd44a233234f05e38814
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:17:12 +02: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
Eskil Abrahamsen Blomfeldt 07d646d1b0 Update imageelements example to Qt 6 url syntax
The imageelements examples depended on URLs being resolved
relative to the file where it was declared, but in Qt 6
this was changed. Since the source is actually resolved
inside MyBorderImage, which is in content/, we would end
up trying to resolve content/content/foo.png.

To avoid having code depend on the location of types it is
using, URLs have to be packed in Qt.resolvedUrl() in Qt 6.

Change-Id: I16e203e92b3b4c7c573dcdb85dcd556f2103ab80
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-17 14:20:01 +02:00
Laszlo Agocs d3412cddab rendercontrol examples: Exercise key event generation as well
Task-number: QTBUG-93489
Change-Id: Ife9db7b066add1f41de964d4c41309568f954320
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-06-15 11:12:21 +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
Laszlo Agocs aab39f5d5d Enable rendercontrol_d3d11 example for MinGW
Pick-to: 6.1
Fixes: QTBUG-92839
Change-Id: Id17417b7ae010566b7f78ea1a6b2cc8fe6abc5e3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-05-19 14:41:08 +02:00
Maximilian Goldstein f7856bc961 examples/quick: Explicitly cast Qt.application to (Quick) Application
Change-Id: Ib9ec9eb0e9f47d8ce758a3c93fee2d1a5abb73ac
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-05-03 13:10:51 +02:00
Maximilian Goldstein 63b418eb54 examples: Use template literals for multiline strings
Change-Id: I660a74730edf60d0b7760162b441e3e14749e930
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-03 10:17:18 +02:00
Maximilian Goldstein 30f9affd16 examples/quick/text/styledtext-layout.qml: Fix warnings
Change-Id: I7c0133d08f306dfb813d02e40f1987e278dd3f4d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-04-30 11:30:06 +02:00
Maximilian Goldstein d21561ca2c examples: samegame4/BoomBlock.qml: Do not use unqualified access
Change-Id: I6e7d6b82605271478bfba9ff614f5748b58fffb7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-04-30 10:57:33 +02:00
Maximilian Goldstein 9a7b31b736 examples/quick/views: Fix a few warnings
Change-Id: Iac5df82ff708e37a0cb985e0b83878e7f9b107e1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-04-30 10:55:58 +02:00
Xiao YaoBing 073f3d23b2 make isRightAligned() const and setNoiseSource() const reference
Guessing the const specifier was accidentally forgotten

Change-Id: I88aaacbd9f8562c8a0b800013bb596c166fae6d7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-03-17 10:21:02 +08:00
Oliver Eftevaag 1d3cdac6e4 Update canvas example to use QtQuickControls2
The QtQuick examples should ideally have a more native look and feel.
Making them use controls from QtQuickControl will cause them to adapt to
the desktop style.

This patch replaces the previous Sliders from the 'shared' directory,
with Sliders from QtQuickControls2

Task-number: QTBUG-90880
Change-Id: I90521abf7059950521bc3d1a54994d2cca07259d
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-03-10 17:53:22 +01:00
Oliver Eftevaag 454da9f721 Update window example to use QtQuickControls2
Replaces the use of custom made components from the shared directory, with QtQuickControls2 components.

Fixes: QTBUG-90883
Change-Id: I6e659188aa75bfacf8181689f30580783bf280a2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-02-23 13:49:51 +01:00
Oliver Eftevaag b2f89bbbb1 Make localstorage example independent of the 'shared' directory
Removed dependency to the components in the 'shared' directory from the
project files. The CMakeLists.txt is generated from the qmake project
file using the pro2cmake.py utility.

Task-number: QTBUG-90884
Change-Id: I4f52a065d02bdfc747a2bca89ad0c1707a7ef9ec
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-02-22 17:10:15 +01:00
Laszlo Agocs 21d9cd844e Fix custommaterial example with OpenGL
The member names in the "uniform block" (which is in practice
mapped to a struct uniform with GLSL) must match between the
vertex and fragment shaders, even if the member is not used in
one of the shaders. This is because OpenGL/GLSL's interface
matching rules, which would cause the shader program fail to
link due to a mismatch in the structs in the two shaders.

Pick-to: 6.1 6.0
Change-Id: I9a928b4b20fdff14530c16a93a52967ce6c328a3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-02-19 10:17:08 +01:00
Oliver Eftevaag 7b263f7bf5 Improve visuals and usability
Usability has been improved when entering new rows into the database.
The user is now only able to write in the input form when editing
an exiting entry or creating a new entry. The warning message associated
with entering invalid input will now disappear after a few seconds.
The ListView delegate is now slightly larger, and looks slightly better.

Task-number: QTBUG-90884
Change-Id: Idf7ca9c0bb8b86ac06fed80e945800603f7b03d9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-02-16 14:31:17 +01:00
Oliver Eftevaag 860928d5c8 Update localstore example to use QtQuickControls2
Removing MyButton.qml and replacing it with QtQuickControls2.

Task-number: QTBUG-90884
Change-Id: Ie1b22e817dedfd71593b074561bdfe2e7dc36008
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-02-16 12:32:52 +01: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
Nico Vertriest b67de9c660 Doc: Fix dead link Qt logo in example
Task-number: QTBUG-80412
Change-Id: Ib97033ec3729a4af2e7404a8ddbb860e574c928d
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-16 07:56:19 +01:00
Alexandru Croitor c1c4a874e3 CMake: Regenerate projects using pro2cmake one last time
And fix up some incorrect qmake project files

Pick-to: 6.0
Change-Id: Ia6d27ac68195635021fe7c4a5f06386a60f3f323
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-10 11:11:58 +01:00
Fabian Kosmale 6eb35df60e QML engine: Deprecate DefaultMethod
Assigning objects to signal handlers can be convenient, as seen in the
examples which use it together with ListView.onRemove.
However, that convenience makes it hard to reason about what actually
happens. Moreover, the only user of that functionality are the Animation
classes, and the usage of DefaultMethod is not documented anywhere.

[ChangeLog][QtQml] Assigning an object to a signal handler is deprecated.
Instead, create the object, give it an id, and call the desired slot
from the signal handler. For instance, instead of of
ListView.onRemove: SequentialAnimation {...}
use
SequentialAnimation {id: removeAnimation; ...}
ListView.onRemove: removeAnimation.start()
A warning will be printed whenever an assignment of an object to a
signal handler occurs. The warning can be controlled via the
qt.qml.defaultmethod logging category.

Change-Id: I001ddf4d7933871977f84a5e012d020fb043cc64
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-12-03 21:12:42 +01:00
Friedemann Kleint 203acb1955 Fix building the d3d11underqml example with MinGW
Fix format mismatch
qtdeclarative/examples/quick/scenegraph/d3d11underqml/d3d11squircle.cpp:369:16: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Werror=format=]
          qFatal("Failed to create buffer: 0x%x", hr);
by casting to uint (as is done in an existing qWarning()).

Pick-to: 6.0
Change-Id: I9bed3066936af8a1831b695a76d40989a834fde9
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-11-26 20:29:37 +01:00
Fabian Kosmale 20641edb37 Make text example work in static CMake builds
Task-number: QTBUG-87702
Task-number: QTBUG-86947
Change-Id: I9dd1b6ca633be60977109acf6b00123d4492b726
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-11 23:40:13 +01:00
Topi Reinio 0b12055548 Doc: Fix documentation warnings for Qt Quick
- Remove links to modules and examples that are not part of Qt 6.
- Remove links to entities marked as \internal
- Add missing enum value and QML property docs where it's trivial
  to do so.

Task-number: QTBUG-88156
Change-Id: I10a1c7bcc5fe0e2354ea69eaf24930362edb7415
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-05 09:00:48 +01:00
Kaj Grönholm 4fd12eef18 Fix CustomAffector example
Don't use particle.r which doesn't exist since the CustomParticle
removal. Make example a bit simpler without this.

Task-number: QTBUG-88173
Change-Id: Id994a9a58796e8194fdccd63c6439d4c19681a45
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-11-05 10:00:37 +02:00
Shawn Rutledge 1469bac17c Add #include <QPainter> in textballoon example
It is not building in namespaced builds without this.
Others also needed this include, such as
qml/tutorials/extending-qml/chapter2-methods/piechart.cpp

Change-Id: Ifbb0557655d247b146ca2eddb07ea6813d9ffacb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-31 09:45:31 +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
Laszlo Agocs fa9808bad0 Fix up shadereffect example docs
The screenshot has been out of date for years now. Update it
as well.

Change-Id: I2b9ae3b0c24b0de7f0cd8a2284d67023237f0944
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-10-23 07:51:59 +00:00