Commit Graph

24 Commits

Author SHA1 Message Date
Eirik Aavitsland 1ebd8ef853 quickwidget example: Avoid potential for crash on close
Widgets that had been broken out to separate top-level windows would
live on after the mainwindow was closed. Subsequent attempts to move
them back to the tab widget would crash, since the that would be
deleted by then. Fix by closing detached top-level windows on
mainwindow close.

Fixes: QTBUG-122790
Pick-to: 6.7 6.6 6.5
Change-Id: I0ae268c5e30b6563dc1556b3f79a83418cc3c703
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-02-29 17:56:20 +01:00
Shawn Rutledge f719ee6408 Avoid crashing in the quickwidgets example after closing the subwindow
Closing the window deletes m_quickWidget; so we disable the menu items
for grabbing from it, because those cannot work. Also add asserts.

Fixes: QTBUG-120296
Pick-to: 5.15 6.2 6.5 6.6 6.7
Change-Id: I68154c2d1e4553c771815e29cbe3b095d85893f1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-01-05 22:50:35 -07:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
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>
2022-06-11 08:05:15 +02:00
Laszlo Agocs a184f2e0ab Make QQuickWidget QRhi-based
When it comes to examples, quickwidget has the direct OpenGL usage
removed because we want this example to be working with any graphics
API. qquickviewcomparison, which features direct OpenGL usage within
its Qt Quick scene, is renamed to a more descriptive name and is also
getting a doc landing page. It continues to be requesting OpenGL (via
QRhi) explicitly.

Change-Id: Iae5b835441f3af229e9746e14dedbe9d1a62b2b9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-18 22:56:54 +01:00
Kai Köhne e2138561df Use QSGRendererInterface::OpenGL in documentation and examples
QSGRendererInterface::OpenGLRhi is only an (undocumented) alias to
...::OpenGL, so let's use that instead.

Amends 0b2311a62b

Pick-to: 6.2 6.3
Change-Id: I4acdd39dc1d9b75bed5c474667a43b4ad86e7f47
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-02-14 11:38:10 +00:00
Laszlo Agocs 4e266103ad Rename setSceneGraphBackend to setGraphicsApi
...and fix up the docs.

The string-based setSceneGraphBackend() stays of course (the docs have
been enhanced, however). The GraphicsApi enum-based overload is now
renamed to setGraphicsApi().

Using the same name for both functions is a historical artifact, reflecting
the evolution (5.0 - 5.8 - 5.14). In 6.0 we can give it a more appropriate
name, since it does not have much to do with "backends" from the user's
perspective.

Change-Id: Id75dbf81f50a148797e5b5de9be4000153737473
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-06-22 16:10:52 +02:00
Laszlo Agocs 0d80dbd8c2 Enable QQuickWidget with OpenGL over RHI
Also adapts to new NativeTexture format, where the actual
handle is passed around instead of a pointer to it.

[ChangeLog][QQuickWidget][Important Behavioral Changes] In
earlier versions, the returned value from QQuickWidget::quickWindow()
would persist for the life time of the widget. This is no
longer the case, so if you are connecting to its signals, make
sure you also connect to its destroyed() signal and update the
connections when it is destroyed.

Fixes: QTBUG-78638
Change-Id: I33cee8543ef1ff5d31555ed3ac18ba78c9c45102
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-05-27 10:45:45 +02: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
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
Liang Qi 15dd1b7883 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/qml/qml/qqmlimport.cpp
	src/qml/qml/qqmlimport_p.h
	src/qml/qml/qqmltypenamecache.cpp

Done-with: Ulf Hermann<ulf.hermann@qt.io>
Change-Id: I41ba7a592b2659ddf53da6952ea3b456a7bba319
2017-10-24 11:13:09 +02:00
Friedemann Kleint f82c4de515 Qt Quick examples: Introduce QCommandLineParser
Task-number: QTBUG-60630
Change-Id: Iaf24e09fdec92f8af495a1288685f266c39be4a7
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2017-10-18 09:45:59 +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
Liang Qi f04c2c40fd Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	src/qml/jsruntime/qv4variantobject.cpp
	src/qml/types/qquickworkerscript.cpp
	src/quick/scenegraph/util/qsgdefaultpainternode_p.h
	tools/qmljs/qmljs.cpp

Change-Id: I876242714ec8c046238d8fd673a5ace2455b2b59
2016-10-18 08:33:26 +02:00
Liang Qi 102fa9b6db Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
	examples/quick/quickwidgets/quickwidget/main.cpp
	src/qml/jsruntime/qv4jsonobject.cpp
	src/qml/jsruntime/qv4qobjectwrapper.cpp
	src/qml/jsruntime/qv4qobjectwrapper_p.h
	src/qml/qml/qqmlengine.cpp
	src/qml/qml/qqmlpropertycache.cpp
	src/qml/qml/qqmlpropertycache_p.h
	src/quick/items/qquickanimatedsprite.cpp
	src/quick/items/qquickitem.cpp
	src/quick/items/qquickitem.h
	src/quick/items/qquickitem_p.h
	src/quick/items/qquickview_p.h
	src/quick/scenegraph/qsgcontext.cpp
	src/quick/scenegraph/qsgdefaultrendercontext.cpp

Change-Id: I172c6fbff97208f21ed4c8b6db3d1747a889f22b
2016-10-10 16:01:48 +02:00
Laszlo Agocs e1a303dd01 Enhance quickwidget example with all grabbing cases
Add a demo of QQuickItem::grabToImage(), in addition to grabFramebuffer()
and render(). This way all possible approaches are demonstrated and tested.

Task-number: QTBUG-55879
Change-Id: I13c427730c416f0d87f83092627e2cb46aba2cc4
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2016-09-22 08:04:05 +00:00
Anton Kudryavtsev 2f9db0a631 examples: replace 'foreach' with 'range for'
While touching the code, replace QStringLiteral
with QL1S in QStringBuilder expression.

Change-Id: I2519b254d82453e1c9bd5b834c0bd78e5c026f83
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2016-09-03 16:50:01 +00:00
Laszlo Agocs b30d970691 Add a tab widget to QQuickWidget example
...and include a tab with custom OpenGL rendering. Tab widgets are
interesting because they are commonly used in applications in combination
with widgets like QOpenGLWidget and QQuickWidget, and because they typically
trigger rapid show-hide sequences which QQuickWidget does not always handle
as well as it could.

Thus this serves both as a helpful example and a useful testing tool.

Plus it exposes at least two bugs already, namely that the continuous
animation in the QQuickFBO does not start when switching to the tab
containing the QQuickWidget in question, and that it is impossible
to integrate third-party rendering code in a robust manner due to
QQuickWidget destroying everything whenever hiding the widget. This
is not what happens with a QQuickView and the normal render loops.

Task-number: QTBUG-54133
Change-Id: Ie7d92cd0f685e4a26f4bb351cc023eb697a36bf4
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2016-06-20 15:50:32 +00:00
Friedemann Kleint 1e2e356f0f Port examples to new connection syntax.
Change-Id: I121c59ac0ad56acb4cd54b99ecd37567368385ce
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
2015-07-22 22:16:19 +00:00
Jani Heikkinen 20c207815a Fixed license headers
Change-Id: I4d5640ff95e1361ec7e65fb3e87d7726d8185ff5
Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
2015-02-17 13:33:18 +00:00
Jani Heikkinen c5796292ad Update copyright headers
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9
Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
2015-02-12 10:28:11 +00:00
Laszlo Agocs 549f76b521 Finish render() support for QQuickWidget
The enablers are already in. Now we just need to use the virtual in
QQuickWidgetPrivate and test it.

Task-number: QTBUG-39562
Change-Id: I1faf5a0a244ba4169fb8f9b0dae657304038b60e
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-08-11 13:19:47 +02:00
Laszlo Agocs 2e4a40a6cc Add support for multisampling in QQuickWidget
Use a multisampled fbo when the requested format has samples > 0.
Resolving happens after each rendering of the scene.

The blit to the temporary non-multisampled fbo could be avoided,
in theory, by sending the fbo instead of the texture id down the
stack and performing a blit directly to fbo #0. This however
involves a number of potential issues, for example due to the
non-sharability of FBOs between contexts. Hence it is left as a
future exercise.

Task-number: QTBUG-39187
Change-Id: Iae98b969bcbc3bb57e6d73288496f5428913c826
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-06-06 12:25:43 +02:00
Laszlo Agocs 337524714c Add surface format to QQuickWidget.
Change-Id: Id72a042588e37832a0d3757bad935c531ef8275a
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
2014-03-18 20:59:55 +01:00
Topi Reinio 5b0935a105 Move Qt Quick Widgets example and document it
Because QtQuickWidgets is part of Qt Quick module documentation,
its examples need to also be moved under the examples/quick
directory structure.

This change moves the example, creates minimal documentation
for it, and adds a link to it from the QQuickWidget class
reference.

Task-number: QTBUG-37272
Change-Id: Iffb67849f150b9aaf0edaef5852364e93f7752b8
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-03-14 09:25:31 +01:00