Commit Graph

2046 Commits

Author SHA1 Message Date
Rym Bouabid
ae0d545d31 Revamp Mandelbrot example: Use a Literal operator to create QString
Create QString at compile time using the literal operator""s instead of
using pointers to characters. This way, no conversion or allocation will
occur at runtime.

Task-number: QTBUG-108861
Pick-to: 6.6 6.5
Change-Id: I4fb51d74abbbfa08fb9fddfa90d8afcebd82a7e2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-09-11 15:05:47 +02:00
Rym Bouabid
a4d7a4ccb3 Revamp Mandelbrot example: Fix Includes
Reorder the includes following the coding conventions.

Remove unneeded includes.

Add needed includes to avoid Transitive includes.

QGestureEvent is passed by a pointer in the gestureEvent method in
mandelbrotwidget.h. So, we do not really need to include the header.
Instead, forward-declare QGestureEvent class in a namespace.

Task-number: QTBUG-108861
Pick-to: 6.6 6.5
Change-Id: I48cfd663bf98350281ef7f31e6c0ef3e301a08ca
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-09-11 15:05:47 +02:00
Edward Welbourne
e53d0220da Turn Directions enum into an enum class in serialization converter
Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ie1f8ea5e2575427528c19875db7a8e4e27200aec
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-09-08 18:17:37 +02:00
Edward Welbourne
ad63118071 Turn Converter::Direction into a QFlags enum
This lets us testFlag() instead of using raw bit-field operations.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I2c26e9a24728e81baa42cf14c75271a015460913
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-09-08 18:17:37 +02:00
Edward Welbourne
77fdd21cbf Serialization converter example: const-ify the Converter type
Its methods act on their parameters without changing the converter, so
can all be const. Its instances thus have no non-const members to
exercise, so can always be const.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ifcdb2f2159c2cfcd7998dd118aa327a32d299ccf
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-09-08 18:17:37 +02:00
Edward Welbourne
eaebb5c4d2 Separate streaming dumper and converter in the convert example
The two were in the same files but mostly unrelated to one another -
aside from the converter defaulting to the dumper for output.
Furthermore, the dumper actually uses QDebug and QTextStream, not
QDataStream; rename it to reflect this reality.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Id65c120c319b555039f7fd186ed262f35ff5260a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-08 18:17:37 +02:00
Edward Welbourne
d8517fb1ab corelib/serialization examples: clang-tidy and coding style clean-up
I overrode clang-tidy where it uglified or obfuscated and did some
clean-up provoked or made possible by its changes. Konrad pointed out,
in review, a constructor that could be = default; it could, in fact,
vanish entirely as a result.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I9b7744a3abaa29e6f9e0689d0f6985bfd88cd0fd
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-09-08 18:17:37 +02:00
Edward Welbourne
319b2e0e86 corelib/serialization examples: use string literals more
A couple more compilation units could use Qt::StringLiterals. Prefer
QL1SV for the code constants, to keep code small. Convert fpToString()
to take QL1SV instead of const char *, with suffix empty by default.
Also rearranged some spacing, some if it suggested by clang-tidy.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I03d810d52afcd4a760d18f2553914b75af716b74
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-09-08 18:17:36 +02:00
Ahmad Samir
09b852b1d8 examples/: compile with QT_NO_CONTEXTLESS_CONNECT
Examples are usually a good way to get to know a new codebase, do not
teach developers who are new to Qt about the 3-arg connect() to begin
with.

Drive-by changes:
- `this` can't be implicitly captured with [=] in a lambda, instead
  capture by reference
- Update docs related to the sqlbrowser example; the overloaded signal
  it mentions has been removed in Qt6
- In the sqlbrowser example, rename addConnection() (no-arg) overload to
  openNewConnectionDialog, suggested in code review

Change-Id: I30c9f35bda4ac2f460d767ab7f84422ae3ed09f7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-08 19:17:36 +03:00
Safiyyah Moosa
a1d308a316 Doc: Add \examplecategory for qtconcurrent
Task-number: QTBUG-116071
Pick-to: 6.5 6.6
Change-Id: I7413a0d8085eec38e6480f6aa21c85620ca68f54
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-09-07 15:05:04 +02:00
Andreas Eliasson
ebd87ce2e5 Doc: Fix qdoc full stop warning in briefs
Add a full stop to the briefs to clear the following qdoc warnings:

* multistreamclient.qdoc: '\brief' statement does not end with
  a full stop.
* multistreamserver.qdoc: '\brief' statement does not end with
  a full stop.

Change-Id: If0e58bc100a595f3ee00c79c31ac19f8d9ee3ad9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-05 21:14:59 +00:00
Edward Welbourne
40b07ee887 Minor tidies in example's XML converter
Make a local variable more local, set a variable only once its new
value is known to be valid.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ib6aa16e8c834f89c6ccc0715f20b0e5f0a7f3b6d
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-09-05 22:41:35 +02:00
Edward Welbourne
d631f88804 Exploit C++17 init-statements in if to simplify a loop
The serialization converter example's text converter's loadFile() can
be made tidier by making the conditions within its loop into a chain.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ic82355eab7380a0c671b3805ca140958bb1c5af5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2023-09-05 22:41:35 +02:00
Edward Welbourne
833ed75b65 Update datastream converter to use Qt_6_0 instead of Qt_5_0
It was added in 5.12 and we've had a few upates since then.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Iacb5368d4baa7d25f981bb0b8bd8d68b5461e17d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-09-05 16:50:53 +02:00
Edward Welbourne
670f66eed3 Core serialization examples: spacing-only clang-format changes
Marc disagreed with clang-format on some, which are thus excluded.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I1402274635dba866a8160a68211874cb11dcfa61
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-09-05 16:40:47 +02:00
Jaishree Vyas
ce47799de6 Doc: Add example categories for qtopengl
Task-number: QTBUG-116069
Pick-to: 6.5 6.6
Change-Id: If675124e538c197d3b446f09da0620718b7b7118
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-09-05 12:28:42 +02:00
Mats Honkamaa
7ef93cbf68 Doc: Add example categories to Qt Widget examples
Added example categories and fixed some minor typos as well.

Task-number: QTBUG-116359
Pick-to: 6.5 6.6
Change-Id: I2e270a1919003f4cea233666b64437e4c2b77121
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-05 07:47:49 +03:00
Assam Boudjelthia
381612f794 Image Gestures Example: use QFileInfo for images file names
The example keeps around image file names only and append
them to the selected dir path, that works fine for file
scheme files, but for Android with content scheme files,
that doesn't work as good because usually the paths are
returned by a provider and managing them manually like
appending a file name to a directory (tree) path might not
work.

This patch retrieves QFileInfo objects and use the absolute
file paths to open any image.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-116181
Change-Id: I9911a181d92ba0452500398cbe052b9583bd79a0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-08-31 22:11:51 +00:00
Laszlo Agocs
80520c2f52 Enable QWidget::grab() with QRhiWidget in the widget tree
This involves reimplementing QWidgetPrivate::grabFramebuffer().
Widgets call this function whenever a texture-based widget is
encountered.

This implies however that we rename QRhiWidget's own, lightweight
grab function, grab(), because it kind of shadows QWidget's grab().
Switch back to grabFramebuffer() which is what QQuickWidget and
QOpenGLWidget both use.

Supporting QWidget::grab() is particularly important when grabbing
an ancestor of the QRhiWidget, because that has no alternative.
Right now, due to not reimplementing the QWidgetPrivate function,
the place of the QRhiWidget is left empty.

In addition, grabFramebuffer() is now const. This is consistent
with QQuickWidget, but not with QOpenGLWidget and QOpenGLWindow.

Change-Id: I646bd920dab7ba50415dd7ee6b63a209f5673e8f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-28 21:14:28 +02:00
Elias Hautala
39a5ed4bdd Exclude some examples from Android build
Excludes  dnslookup, waitconditions, semaphores, cbordump, savegame,
convert, pingpong and complexpingpong examples from Android build
because of missing Qui and Quick dependenies.

Task-number: QTBUG-111933
Pick-to: 6.5 6.6
Change-Id: Ied01f62ee61a9220dcb44c13fda46f6a5e158293
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-08-28 16:00:45 +03:00
Safiyyah Moosa
3b187f14a1 Doc: Add \examplecategory to qtgui
Task-number: QTBUG-116068
Pick-to: 6.5 6.6
Change-Id: Ia0bdc2122434adac51b37ba2207a2b0b993cf19b
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-08-28 13:49:36 +02:00
Ahmad Samir
0b3390f33d examples/: fix compiler (GCC) warnings -Wsign-compare
Change-Id: Ie4965e3ce3113e9c7a5d5d5eba4cab143ef1c806
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-18 23:35:52 +03:00
Ahmad Samir
ad6fd04609 examples/: fix compiler warnings -Wdeprecated-enum-float-conversion
This is with GCC.

Change-Id: I52dcb6881f36c740129b699db7db9241a4e75da1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-18 23:35:52 +03:00
Ahmad Samir
339323b999 examples/: implicit capture of this via [=] is deprecated in C++20
Change-Id: I43b04517e9e3a30468c8ce702c9a49968c0ddc4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-18 23:35:52 +03:00
Mårten Nordheim
5be45ff6a6 Multi-stream* example: add simple docs
To make it show up in the documentation.
It's also our only example showing SCTP.

Change-Id: Ib80ab869d9a6cbd370aa1a0c74772639e4393b37
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-08-17 13:15:00 +00:00
Mats Honkamaa
4e009da7ef Doc: Add example categories for Qt Network examples
Task-number: QTBUG-116001
Pick-to: 6.5 6.6
Change-Id: I0c32df7752347f7c38996b3815d270dbd4c90707
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-08-16 15:56:50 +03:00
Laszlo Agocs
d48831612a examples: Add new subdirectory to examples/widgets CMakeLists
Already there in the .pro.

Change-Id: I2f4312310b80ad3403f242ba387218e8ec86bcb4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-08-15 01:11:03 +02:00
Laszlo Agocs
72a453c6a8 Add QRhiWidget
Task-number: QTBUG-113331
Change-Id: I8baa697b4997b05f52acdee0e08d3c368fde5bc2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-14 17:05:36 +02:00
Mats Honkamaa
b1c062d078 Doc: Add example categories for Qt D-bus examples
Task-number: QTBUG-116030
Pick-to: 6.5 6.6
Change-Id: I6ad7ddb69fc952d3bba7477ab804455d46d77866
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2023-08-14 17:08:33 +03:00
Edward Welbourne
fd7fbaf887 XBEL stream reader: rework documentation
Document previously-undocumented methods. Document in terms of what
each thing achieves, not how it does it. The U+00B7 is not the period,
it is the centred dot. Fix various anachronisms; the existing docs
were out of date with the actual code.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I17da880e0afd7260aa6f3b7bdddb430c437f4562
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-08-03 19:16:27 +02:00
Jani Korteniemi
b3127806a7 Update Android notifier example to match example guideline
Replaced add_subdirectory() with qt_internal_add_example().
Added tags.

Task-number: QTBUG-114638
Change-Id: I397c2974a51f0bea391099d1d1abfea39bd29cbe
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-08-02 15:47:15 +03:00
Amir Masoud Abdol
95ed8d1fd9 Fix the project name
Fixes: QTBUG-115327
Pick-to: 6.2 6.5 6.6
Change-Id: I77fc3a98d1658609caa9618430f6e6823b8e1bb5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-31 12:38:40 +02:00
Edward Welbourne
63de44f1d3 Add missing \l to DOM bookmarks example
It tried to reference the QXmlStream equivalent example, putting its
title in {...}, but neglected the \l prefix to that.

Change-Id: Iedc556ecd65103057d0dea65debe628b50d1190e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2023-07-25 12:31:04 +02:00
Mårten Nordheim
0b10808fb5 Network-chat example: update the screenshot
Change-Id: Ibdb9e242295766304c1c7a551d831fb796518496
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-17 18:49:16 +02:00
Mårten Nordheim
2a80adc2f6 Network-chat example: Use QHash for peers
We don't key it on IP address anymore so we can drop
the use of QMultiHash.
This also requires moving the connections for error and disconnected
to readyForUse so we don't remove an active connection when a second
connection attempt happens from the same peer process.
But since we still need to deallocate those connection attempts
if they error out or simply disconnect, we connect their signals to the
QObject::deleteLater slot. In some cases we might call deleteLater twice
but that's fine.

Change-Id: I48c27de1e51a52ef61cfb941a7a81b358ae9ce3f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-07-17 18:49:16 +02:00
Mårten Nordheim
226d06402b Network-chat: Fix remote peer making multiple connections
The system was just treating IP (and optionally port) as a unique
identifier, so if a peer had multiple possible paths to a client they
would connect multiple times.

This fixes that by generating using QUuid in each client.
We then use this during broadcast, replacing the username we
sent before (which was not used), and as part of the greeting.
The greeting now is more complex, since we need to send both
username and the ID.

Change-Id: I6c6c2ffd5198406aad48445a68dd6aab36de69c0
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-17 16:49:16 +00:00
Edward Welbourne
5651be517a XBEL stream example: use constructor initialization
The treeWidget member of MainWindow could be initialized before the
body of the constructor, enabling it to be a *const variable.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: If4a3b04729bc7fa5859ca88183eec376f6992455
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-07-17 14:50:51 +02:00
Paul Olav Tvete
631cb589bf Doc fix: Use correct initials for Porter and Duff
It's Thomas Porter and Tom Duff, not Xavier and Yoann.

Pick-to: 6.6 6.5
Change-Id: I2e9345c06c299e9c0475831e21c3b9b85c58a32f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-07-14 14:56:42 +02:00
Kai Köhne
c07a3f10ef Doc: Add remaining SQL examples to Data Processing & I/O category
Task-number: QTBUG-115174
Pick-to: 6.5 6.6
Change-Id: Idd8ba8504efb17f0e4a11b3c36b991739251f2ef
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2023-07-13 16:19:05 +02:00
Mårten Nordheim
9777fd0257 broadcast{receiver,sender}: update meta info
Change-Id: I864de05a766fa4e5b9b7fdec7c2b95ac2b576c26
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-12 11:29:55 +02:00
Mårten Nordheim
bec7c39950 DnsLookup: add some documentation
Just to make it show up in the docs.

Change-Id: I22e9a1eb7dd040e76ee68f3f63053b030733b33d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-12 11:29:54 +02:00
Mårten Nordheim
d3526c166c securesocketclient: Update meta info
Change-Id: I34b11cd73c80dc3033de8731bd8edc0db3ed4a12
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-12 11:29:28 +02:00
Mårten Nordheim
f89bf4f25d securesocketclient: Replace the screenshot
Change-Id: I73658fef13ac4fdc046011f6aa68b6f97555546a
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-12 11:29:25 +02:00
Mårten Nordheim
d34952a3d1 securesocketclient: Replace QLatin1Char with char16_t literal
Change-Id: I3efebe12e3a46c35e6c1775226e9ba424811cc30
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-07-12 11:29:22 +02:00
Edward Welbourne
e8a68b556c XBEL streaming example: renumber xbelreader.cpp's snippet fragments
I'll be adding docs for parts currently lacking them; fix up the
numbering first, to disentangle from "real" changes to docs.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ia10f212626bf5ca9fab2b6ba6cf02dbd560a2f02
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-07-10 12:57:21 +02:00
Edward Welbourne
98765cab97 XBEL streaming: shuffle mainwindow parts into more pedagogic order
Renumber the code fragments to match their order, while adding a
number for the previously undocumented custom method. Add a brief
description of it. Move the createMenus() part up to after it, combine
the createActions() with its (as createActions() is long gone, fused
into it and sharing its snippet number).

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: If0fbcadfa058fc12cbd74ba1897646113bd016b0
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-07-10 12:57:20 +02:00
Edward Welbourne
bb69def7d1 XBEL stream example: move createMenus() earlier
This will make the description of the type flow more naturally.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I751bdaf420be7afc9cb4925af4f2a94367840605
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-07-10 12:57:20 +02:00
Edward Welbourne
acb950c129 XBEL DOM example: update the screenshot
The old one showed an old XBEL file's content, with trolltech URLs.
Update to match the new XBEL file's content.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I2b3bb7d67c6f96b04208fe4b1f9af10055dc0496
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
2023-07-10 12:57:20 +02:00
Edward Welbourne
a028e53fa4 XBEL streaming: replace images with up-to-date version
The old screenshot showed an old XBEL file's content, with trolltech
URLs. Update to match the new XBEL file's content.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Idacc31b7786b1e6ed1425857470b1d37227096cd
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-10 12:57:20 +02:00
Edward Welbourne
4731cdc09d Update XBEL examples' sample data file
Most links are now https, several have relocated, one entirely
rebranded. Same example in both QXmlStream and DOM forms.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ifbc58dadc834cf51113adb1c82de971a8768ee58
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2023-07-10 12:57:20 +02:00