Commit Graph

1878 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov
2834d4263a remotecontrolledcar example: Move car.xml to common directory
It is shared between car and controller executables.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I5f98a09664671c55bfad68ebf88c9f0c734511fa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-20 17:15:00 +01:00
Ievgenii Meshcheriakov
5cd7900d4f remotecontrolledcar example: Move executables into single example project
This allows building of all the example executables at once.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I1fa372ec9725bfeb1f123305aa7324b7820eb593
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-20 17:14:59 +01:00
Ievgenii Meshcheriakov
20668baa59 dbus examples: Update screenshots
Use WEBP format to reduce the file size.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I14ff15010e7ac7e1b375eeafaa1c153b0fdd95e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-14 19:46:08 +01:00
Ivan Solovev
0ac234f9e2 Imagescaling example: fix memory leaks
* The DownloadDialog was never destroyed properly. Pass 'this' to its
  constructor to fix it.
* When re-creating an image grid layout, properly clean up old image
  labels in Images::initLayout()

Task-number: QTBUG-103514
Pick-to: 6.5 6.5.0
Change-Id: Ief52774002632d4ad3a6cca85bb0c0aa1a1d4bc0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-03-13 19:24:14 +01:00
Andreas Eliasson
9f93f96394 Doc: Remove broken link to Anchor Layout Example
This example was moved to manual tests in 6.5, which broke the link.
Now that it's in manual tests, I guess we can stop promoting it.

Pick-to: 6.5 6.5.0
Change-Id: I1aa4a7de5123e96bf9ff56eeae49104acdce9645
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-03-13 08:12:01 +00:00
James DeLisle
ed6a3ce0af Update the bindable properties example
- Fix the number of months in each duration
- Move the user Country enum to use QLocale::Territory
- Properly calculate the cost per month to match the UI label
- Use QLocale to format the price display text
- Fix some misspellings and grammar in the doc

Pick-to: 6.2 6.5
Change-Id: I78a64f344073070cd94d5cb4a8a4c7c13afa337f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-03-09 12:27:00 -05:00
Dennis Oberst
de5e0422ca Example: remove runfunction example
This example shows how to use QtConcurrent::run by calling a global
function and printing the thread ID. As the documentation already
explains the functionality very well, I don't think this example is
necessary.

https://doc.qt.io/qt-6/qtconcurrentrun.html

Task-number: QTBUG-111165
Pick-to: 6.5 6.5.0
Change-Id: I42a718cdaabdaeeab39b933d12c67d11978c95da
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-03-09 17:26:59 +00:00
Dennis Oberst
fbb470b40b Example: remove map example
This example only demonstrates the use of blockingMapped. Considering
that the QtConcurrent::mapped~ functions are already included in the
wordcount example, and have very similar APIs to the
QtConcurrent::filter~ functions, which are included in the
progressdialog example, this no longer serves a useful purpose.

Task-number: QTBUG-111165
Pick-to: 6.5 6.5.0
Change-Id: Ibc526e1a9fb17070e376e45151e9c2bdbc69bd32
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-03-09 17:26:59 +00:00
Dennis Oberst
b5e9d41895 Example: update imagescaling example
Updated the example to align with the Qt6 Example-Guideline.

https://wiki.qt.io/Qt6/Example-Guideline

Task-number: QTBUG-111165
Pick-to: 6.5 6.5.0
Change-Id: Ibd9e7ce0d4dee90f6a693b81516d2f5b86345b1d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-09 17:26:59 +00:00
Ievgenii Meshcheriakov
eea83bac26 dbus examples: Remove listnames example
Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I5c483cbfec4072dae610c6d98b97d10057ba9ddc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-03 12:46:29 +01:00
Mårten Nordheim
bdcb0a32fa HTTP example: update screenshot
Fixes: QTBUG-108874
Pick-to: 6.5
Change-Id: Ib87895c6512abb967734ce4c1ed0be76c698feb4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-03-02 18:39:09 +01:00
Jan Arve Sæther
5773c3ac28 Move anchor layout example to manual tests
Pick-to: 6.5 6.5.0
Change-Id: I9c9a9dbcdaf705a31208b80b71e978938a492142
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-03-02 17:24:53 +00:00
Øystein Heskestad
e13b57d06a Move xmlstreamlint example into tests/manual
This example is useful but not a typical starting point for an
application.

Task-number: QTBUG-110647
Pick-to: 6.5
Change-Id: Ic4af8ed648c587b91110a7403fa80c619549289d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:20:18 +01:00
Øystein Heskestad
56b3123689 Remove htmlinfo example
This example is removed because what it does is already covered by the
other XML examples.

Task-number: QTBUG-110647
Pick-to: 6.5
Change-Id: If33e3fc55dcd9c7c10cfdfa86405f8bcf5cb6187
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:20:17 +01:00
Volker Hilsheimer
3c104c2799 Remove the 'sdi' example
It is essentially the same as the other mainwindow examples, showing
how to create a text editor. The only special code here is the tiling of
the different main windows, which - without any documentation or
explanation - is neither very helpful, nor relevant in 2023.

Pick-to: 6.5
Change-Id: I48b92b1cf057f586e0d2842d1c0a3312154e9a13
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-03-02 12:08:11 +01:00
Mårten Nordheim
277d809ba4 DNS Lookup: Use ideomatic cstdio include
Task-number: QTBUG-108873
Pick-to: 6.5
Change-Id: I646f0c985adc45a17103b5f98394f3def4b6ada2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-03-02 12:08:10 +01:00
Mårten Nordheim
af95f97466 DNS Lookup: Change local function to return struct instead of enum
This let's us get rid of an out-parameter.

Task-number: QTBUG-108873
Pick-to: 6.5
Change-Id: Ifc08d3905932f28ecdfdf3a7de1499700cc7e606
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:08:10 +01:00
Mårten Nordheim
83dac21813 DNS Lookup: Use standard functions to print version/help
showHelp was already in use, but not showVersion.
Return 0 in both cases, even if it's unreachable.

Task-number: QTBUG-108873
Pick-to: 6.5
Change-Id: Iba820e89d7de066130163e7829f75bbfcfa3f7dd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:08:10 +01:00
Mårten Nordheim
a6dc860915 DNS Lookup: reflow some code to avoid exceeding column limit
Task-number: QTBUG-108873
Pick-to: 6.5
Change-Id: Ic17ded256152f7d89bd200ea0e163f2b8f1ea70a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:08:10 +01:00
Mårten Nordheim
b300c6b777 DNS Lookup: Use std::optional instead of casting enum to int
Task-number: QTBUG-108873
Pick-to: 6.5
Change-Id: I0bd5dc004154c1c4026be2feb6187c53e5e77801
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:08:10 +01:00
Mårten Nordheim
5e16397a2c DNS Lookup: Avoid unneeded allocations in parsing function
By using .compare(~~~, Qt::CaseInsensitive) instead of .toLower()

Task-number: QTBUG-108873
Pick-to: 6.5
Change-Id: I60e1fdc0a54450e7385e90f84fd509e62b82d2c9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:08:09 +01:00
Mårten Nordheim
eb61d49ab3 Delete the Network Download (Manager)? examples
Their use of QtNetwork is already covered by the HTTP example.
While showcasing that QNAM easily deals with multiple simultaneous
requests, waiting until finished() is emitted to write anything is not
exactly idiomatic.
And managing your own queue to only have one request running at a time
is a weird example for an asynchronous framework.

In this regard, having an example for a complete download manager
(with a GUI) would be interesting, but may ultimately be very
time-consuming to make for limited gain.

Task-number: QTBUG-110643
Pick-to: 6.5
Change-Id: I6b2c1546b85fa89ab7ce1ff5565b0293b5710b74
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-03-02 12:08:09 +01:00
Jan Arve Sæther
a84b2e5973 Move Weather Anchor Layout example to manual tests
Pick-to: 6.5
Change-Id: I8782a83b5c12b4f57bf9ef9063818cb124bddd56
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-03-02 05:55:57 +01:00
Volker Hilsheimer
721b4a4b5a Doc: move snippet for implicit translation context
The 'sdi' example is a candidate for removal, so point at the
spreadsheet example instead, which is not.

Pick-to: 6.5
Change-Id: I4405f2421db8be79898a38ca4f3fa1ea5fe0280b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-03-01 22:22:26 +01:00
Volker Hilsheimer
a02fb41c8e Doc: fix links to renamed network examples
Pick-to: 6.5
Change-Id: I8790bb660070a092e268294b5640c6d5af41deb0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-01 19:14:39 +01:00
Ievgenii Meshcheriakov
f952e74cfe pingpong example: Remove pong.h
Move the class definition inside pong.cpp.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Id4b376451cb2bdbd04ccce4b2dcf0760dbfbfb2a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-28 18:15:24 +01:00
Ievgenii Meshcheriakov
07b8a5a409 pingpong example: Modernize the code
Use qWarning()/std::cout instead of C IO functions.

Use default parameters for QDBusInterface's constructor.

Remove useless Q_SCRIPTABLE.

Use type-safe invokeMethod().

Extract a local variable for the used D-Bus connection.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Idc38a7c1dd97d71308d9491193039744c759d6f2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-28 18:15:24 +01:00
Andreas Eliasson
8ecd81ae86 Doc: Remove duplicate words
Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7
Pick-to: 6.5 6.4 6.2
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-02-28 16:53:10 +00:00
Mårten Nordheim
97dcf1ba18 Fortune* Example: update screenshots
Fixes: QTBUG-108875
Pick-to: 6.5
Change-Id: Ib57482959973815681b0b178acea3634a4f63220
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-28 16:33:05 +01:00
Laszlo Agocs
6462a454e3 Remove threadeqopenglwidget example
It is neither documented nor very useful, and it has
platform-specific issues as reported over the years.

Remove it now as part of the example revamp initiative.

Task-number: QTBUG-50278
Task-number: QTBUG-110093
Task-number: QTBUG-76054
Task-number: QTBUG-43209
Pick-to: 6.5
Change-Id: I6dadaf4162b4c19411c544b9f204c19e37aa740d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-02-28 14:28:51 +01:00
Ievgenii Meshcheriakov
742e79312f chat example: Update code style
Use lambdas instead of slots where practical.
Consistently use signals to transmit D-Bus messages.
Extract a local variable for the used D-Bus connection.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Icc6667e1392ada1b7d3b33c4e4b32917dd648390
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Ievgenii Meshcheriakov
57d25b3a53 chat example: Remove empty destructor
Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I880c16638c992a4ee8528b1c545e6f563a7efa8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Ievgenii Meshcheriakov
fd03a04457 chat example: Remove commented-out code
Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Ib8e89427357f604ab30cb0de50eb373cffb945fa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Ievgenii Meshcheriakov
8b48657590 chat example: Use QInputDialog to get a user nickname
This gets rid of a custom form. Also quit the application if user
closes the input dialog without entering a nickname.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I56ed99d69d031e7ef06711fc7ec112311c974ca6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Samuel Gaist
283cdb0e70 examples: port widget examples to new connection style
Task-number: QTBUG-106893
Change-Id: Ib10fd516fdbeda0087b1c8550ce340acd3973e6b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-25 22:11:57 +01:00
Yuhang Zhao
f7fd5eaf95 Fix qtbase build when all deprecated code are disabled
Adjust the callers to use the non-deprecated APIs.

Pick-to: 6.5
Change-Id: I8e96f25684a2d613bc400a8626dc9e3af2bb8dcf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-22 22:27:35 +08:00
Mårten Nordheim
32098963f2 Torrent example: Fix use-after-free crash
The crash would sometimes happen shortly after removing a torrent
since the RateController would still try to use it even though
it had been deallocated.

Pick-to: 6.5
Task-number: QTBUG-110622
Change-Id: Icad1531ea58560a3a3157a3ed8c0e6b283573196
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-02-21 13:04:44 +01:00
Mårten Nordheim
f3de92cdad Torrent example: Fix some stack overflow issues
Because of the .size() used as part of the expression it
ends up copying sizeof(qsizetype) bytes to the array,
instead of the (rationally) expected 4 bytes.

Amends 69c31f6f68

Pick-to: 6.5
Task-number: QTBUG-110622
Change-Id: I732e3f4bb5934ff3860087baa91f9bebbf044a7f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-02-21 13:04:44 +01:00
Mårten Nordheim
d3c1445419 Torrent: simplify QBitArray usage
There is specific API for counting number of 0-bits

Pick-to: 6.5
Task-number: QTBUG-110622
Change-Id: Ifa33862ff7b98a59f362bc52c492e8a037799835
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-21 13:04:44 +01:00
Tor Arne Vestbø
850ef55fc5 examples: Connect Quit action to QCoreApplication::quit, not QWidget::close
Pick-to: 6.5
Change-Id: I44ca7b61a4a261a7d3aad0dfeb870eb927ee768d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-20 15:18:18 +01:00
Tor Arne Vestbø
f99df42646 mainwindow example: Don't assume toolbar parent is main window
Adding the toolbar to the main window leaves it up to the main window
how to handle ownership and placement of the toolbar.

Pick-to: 6.5
Change-Id: Id429cbad9d5973931a86fcb899684e3651694fbb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-20 10:33:10 +01:00
Mårten Nordheim
22fc1d08bb Torrent example: delete unimplemented functions
That's not fit for an example...

Task-number: QTBUG-110622
Pick-to: 6.5
Change-Id: Ib196d61867f95f3ff2e45841509d49df9360ad25
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-14 18:49:46 +01:00
Mårten Nordheim
3fc26dbb2c Torrent example: Convert some timeouts from int to chrono
Using seconds because then they all have the same type, even if
all-but-one could use minutes.
Delete one unused interval value.

Task-number: QTBUG-110622
Pick-to: 6.5
Change-Id: I66b456de8a4b867859e9e2b13ce72e8ec691c79a
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-14 18:49:45 +01:00
Mårten Nordheim
69c31f6f68 Torrent example: Remove manual little-big endian conversion
... and use QtEndian instead.

The conversion would be done even on a big-endian system, so the
example would not work correctly on such machines.

Task-number: QTBUG-110622
Pick-to: 6.5
Change-Id: I6a660ff68fa5a8d9b4c1faf9e264d937c605c47e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-14 18:49:45 +01:00
Mårten Nordheim
2145341071 Delete googlesuggest
As a networking example it doesn't contribute much. But it has some
interesting uses of widget/events

Pick-to: 6.5
Change-Id: I194d32e6a304ae41819c20751e9f1ee1d9b5abdb
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-02-14 17:48:09 +01:00
Volker Hilsheimer
48a1a5564f Examples: move widgets/codeeditor into manual tests
It's not a very well written example, using (largely unneed) hacks to
implement what it does. It's also misleading - the syntaxhighlighter
example is a better showcase for building a useful code editor.

Move it to manual tests.

Fixes: QTBUG-111025
Pick-to: 6.5
Change-Id: I405d41688235bf3e9a08373e716769f26d02fec6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-09 00:23:34 +01:00
Volker Hilsheimer
3fe0bf6e1b Move findfiles example into manual tests
The example follows bad and outdated practices:

- running time consuming and I/O heavy workload in the GUI thread
- calling processEvents to keep the UI responsive
- showing results only at the end of a search rather than continuously

Perhaps this example can be rewritten at some point to apply modern
practices (at least use a thread and emit signals), but it seems
to have low overall educational value.

Moving it to be a manual test for now.

Fixes: QTBUG-111002
Pick-to: 6.5
Change-Id: Id630fd4599096448ea4f96bcbf977b11a039796f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-09 00:23:34 +01:00
Volker Hilsheimer
55f2b448b0 Turn elidedlabel example into a code snippet
The example is 90% boiler plate for subclassing QFrame and providing
a bit of GUI to change the size of the label using sliders. The
interesting bit is a block of 25 lines of code, so turn those into a
snippet and add that to the QTextLayout overview documentation.

Fixes: QTBUG-111011
Pick-to: 6.5
Change-Id: I6e97b2ea47b553c8d998ad185cfac006721ef7ee
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-09 00:23:33 +01:00
Marc Mutz
ac6e8b3b21 savegame ex.: fix include order [2/2]: game.h
Includes should be ordered from most specific to most general. This
means that project-specific includes always come before Qt includes.

This example didn't follow that guideline. Fix.

Amends 88e8094f18.

Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Iafdae9dd8e70ff99882c4344a023a21d15fa3c54
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-08 18:24:17 +01:00
Marc Mutz
fa55d46e1f savegame ex.: make Level ctor explicit
A QString is not a full representation of a Level, so the
Level(QString) ctor should be explicit.

Pick-to: 6.5 6.4 6.2 5.15
Task-number: QTBUG-108857
Change-Id: I24b705139e61c4aaf59cb0aad3b536013e0d07df
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-08 18:24:16 +01:00
Marc Mutz
4493334393 savegame ex.: use ranged instead of indexed loops
Modernizes the code, and fixes qsizetype/int mismatch.

Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2
Change-Id: Id4262ee0bcb673d62135a81c30976903eef3e5e2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-08 08:37:21 +01:00
Marc Mutz
35b94f8b43 savegame ex.: use NSDMI, =default the default ctor
Modernizes the code.

Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I6ddf1de3699506ffc0fc4b1034ab48defafcf174
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-08 08:37:21 +01:00
Marc Mutz
88e8094f18 savegame ex.: fix include order
Includes should be ordered from most specific to most general. This
means that project-specific includes always come before Qt includes.

This example didn't follow that guideline. Fix.

Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I42727ff8bdef5336368cde349cbcb8d10bb6289f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-08 08:37:21 +01:00
Marc Mutz
06a9b85f8f savegame ex.: fix extra ';' after Q_GADGET
Fixes compiler warnings.

Amends 1ff52e478b.

Task-number: QTBUG-108857
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Id8b81c67e55baf490aabd0483b5800b3e61965ee
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-08 08:37:21 +01:00
Tor Arne Vestbø
a3697f2b84 permissions: Replace deprecated location permission usage key
And add the macOS specific key.

Pick-to: 6.5
Change-Id: I1e0446a1927ef530322388417b9300ae287752c3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-02-08 00:13:55 +01:00
David Schulz
834e97ce46 Add android manifest and java files to example
These files should not change the outcome of the build process, but are
merely added to better support the CMake and Android integration in
Qt Creator. Also those files were previously listed in the OTHER_FILES
section of the qmake project files.

Change-Id: Id3d403130ee8800ed6b0877f9f1c3dd1f28b46b7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-02-07 18:34:42 +01:00
Jan Arve Sæther
f7db1cfa92 Remove "Analog Clock Window Example"
This is almost exactly the same as the "Analog Clock" (widget) example.
"Analog Clock Window Example" demonstrates:
* How to render to a QWindow (covered by RasterWindow example)
* QPainter and transformations (covered by Analog Clock example)
* How to use QTimer (covered by Analog Clock example)

Pick-to: 6.5
Change-Id: I7f20a29798830ed6345eca250e4139cb314cab84
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2023-02-07 17:34:42 +00:00
Tor Arne Vestbø
0c2ee11f41 permissions: Set explicit bundle identifier for permissions example
It's needed for location permissions to work.

Pick-to: 6.5
Change-Id: Iffb5d92f863ab79434b4071d5896b349010f87fb
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-07 13:33:02 +01:00
Mårten Nordheim
7df8ef0a10 HTTP example: Reflow QMessageBox usage in if-statement
It gets hard to read like that.
And update mentions of 'SSL' to 'TLS' in the message while we're there.

Task-number: QTBUG-108874
Pick-to: 6.5
Change-Id: Ia7b27bfb3d99391b14ed396ca9a6400621022bf6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-02 18:03:36 +00:00
Jan Arve Sæther
fd65f70974 Fix analog clock example to adhere to guidelines
Guidelines: https://wiki.qt.io/Qt6/Example-Guideline

Pick-to: 6.5
Change-Id: I12c65ae11e7906fd2e9dfb449072199560488aed
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-02-02 17:51:34 +01:00
Tor Arne Vestbø
1f1380b79c permissions: Finalize permission example at end of CMakeLists.txt
Otherwise the finalizers won't know which libraries we're linking to.

Pick-to: 6.5
Change-Id: I886c46443b7289d6e2c7d824767ed5e34a0a1fbf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-02-01 20:25:08 +01:00
Friedemann Kleint
93af309a70 Examples: Fix CMake Unity (Jumbo) builds
Disambiguate variables and add some exclusions.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ie72b3caab9fd571c3fb6f7d8606584885bc09e66
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-02-01 19:12:36 +01:00
Friedemann Kleint
ddb94dd792 Examples: Add missing include guards
Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-109394
Change-Id: I09a1b522d0faeb2346e1e075141f1e810c8155f7
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-01 18:12:36 +00:00
Jan Arve Sæther
e08575a18a Remove wiggly example
It demonstrates timerEvent() and some QFontMetrics
There are other examples that demonstrates this

Pick-to: 6.5
Change-Id: I4ad6f30c8ef93c995f980545ed88ab13b9aa9c7d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-31 22:28:30 +01:00
Jani Korteniemi
4b4873359d Fix ContextInfo example crashing on Android
Disabled desktop OpenGL renderer on android

Task-number: QTBUG-91627
Pick-to: 6.2 6.4 6.5
Change-Id: I61ec7cc768d46c368dc0187714bd0bd085257a67
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-01-31 20:52:40 +02:00
Volker Hilsheimer
cb0bf5ad68 Merge "undo" and "undoframework" examples
The "undo" example didn't show anything that the "undoframework"
example doesn't, and the latter is more comprehensive and properly
documented. "undoframework" also uses QGraphicsView instead of
inventing its own diagram widget.

However, the "undo" example created a nicer UI with toolbuttons,
icons, and the undo view in a dock widget, so reuse those elements
in the "undoframework" example instead.

Update the documentation quoting tags accordingly, and clean up
a bit.

Pick-to: 6.5
Change-Id: I3c91feecbd5fe3e5900838b0b51f9fe7bd190280
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-01-31 00:20:31 +01:00
Mårten Nordheim
39daa368d4 Torrent example: Use QByteArray toPercentEncoding
The hand-rolled loop produced incorrect output and was subsequently
rejected by trackers.

The torrent example doesn't support modern features though, so it's
still a bit hit-or-miss whether a torrent will work. E.g. downloading an
Arch iso does not work since it relies on DHT, PeX and HTTP seeds.

Fixes: QTBUG-109798
Task-number: QTBUG-110622
Pick-to: 6.5
Change-Id: Ica40fb9205f09d135407a160a28a45d06a418176
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-30 20:10:25 +01:00
Mårten Nordheim
6c90c04fb9 Torrent example: don't try to announce to an empty URL
Task-number: QTBUG-109798
Task-number: QTBUG-110622
Pick-to: 6.5
Change-Id: I3603232eb094387388da6421bf5525a3ba54fe03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-30 20:10:25 +01:00
Jan Arve Sæther
2db23e151f Adhere to https://wiki.qt.io/Qt6/Example-Guideline
* Remove "Example" suffix in title

Pick-to: 6.5
Change-Id: I5da311850ab8f725da363969d7a8d8a1a85f8d70
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2023-01-26 16:07:47 +01:00
Mårten Nordheim
5006fddd33 HTTP Example: Add proxy handling
If a proxy is configured on the system then we will request credentials
if needed.

Task-number: QTBUG-108874
Fixes: QTBUG-106245
Pick-to: 6.5
Change-Id: Icbea491492cde4634421b1a1e722a3768d56dec8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-24 20:11:53 +01:00
Mårten Nordheim
d18b5195c1 HTTP example: remove needlessly unset-ing window flag
In Qt 6 it is unset by default.

Task-number: QTBUG-108874
Pick-to: 6.5
Change-Id: I35af9d7c1517fd393710b7b1b978d3f39c61acf0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-24 20:11:53 +01:00
Mårten Nordheim
c89c37b52f HTTP example: Fix missing translation and improve others
As a drive-by: print the path with native separators

Task-number: QTBUG-108874
Pick-to: 6.5
Change-Id: I73164acb159d1a45960e16d5f57996e8c27257f7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-01-24 20:11:53 +01:00
Mårten Nordheim
7c90881a8e HTTP example: rename to HTTP Client
It can do more than HTTP but let's keep the naming simple. Most people
likely aren't looking to do file: or data: or qrc: in this example.

Task-number: QTBUG-108874
Pick-to: 6.5
Change-Id: I8a822640f4a8015ebf6c56cb6a614d6426e8a912
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-24 20:11:53 +01:00
Mårten Nordheim
5bc644c951 Fortune* Example: Rename and add category/tags
Task-number: QTBUG-108875
Pick-to: 6.5
Change-Id: I8eeff88187be4f85514d9871eb5009c51ad6de64
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-01-24 20:11:53 +01:00
Axel Spoerl
2ae75c2e6a Fix CMakeLists.txt of Style Plugin Example (broken on macOS)
Add TARGET instruction in property setter, used in debug mode on macOS.

Task-number: QTBUG-107842
Task-number: QTBUG-109227
Change-Id: I8704b7009c36ea8ddbf8773abfaf2b5f34f728ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-01-19 10:50:04 +00:00
Amir Masoud Abdol
7fe2537ce2 Fix Style Plugin Example, and add some CMake Docs
A few things:

- Improved the documentation by adding a CMake section, briefly
  describing the process of adding the plugin, and placing it where it
  should be.
- Write a note about the case where the style may be overwritten at
  launch, and how to set the a new style using a CLI
- Improved the CMake build such that it creates the App Bundle
  correctly, and also works without an App Bundle as well.
- Changed the example, and plugin such that now instead of a QPushButton
  we have a QTextEdit, and change the text color.
- Replaced the application screenshot

Fixes: QTBUG-107842
Fixes: QTBUG-109227
Change-Id: I161a91b27df016ff6230fac3871b79d2dfbdf18a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-01-18 14:47:12 +01:00
Mårten Nordheim
2fe69dbeb8 Fortune* Example: remove needless unset-ing of window flag
It's unset by default in Qt6.

Task-number: QTBUG-108875
Pick-to: 6.5
Change-Id: I3f1c6e4e6de54e9ca0ed8892f9da1d346d16d4c7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-01-17 16:15:11 +01:00
Mårten Nordheim
71cd3bc074 Fortune* Example: Bump QDataStream format version
One of the examples were using a different version than the others.
Though QString's formatting probably didn't change since then so
it was no problem.

Anyway, pretend like we're releasing it now for the first time and
set 6.5 on all of them

Task-number: QTBUG-108875
Pick-to: 6.5
Change-Id: I28b496ab3d8ff54c503a032ba15882cdf3d5eccf
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-01-17 16:15:11 +01:00
Mårten Nordheim
605eec7b55 Fortune* Example: convert simple for-loop to ranged-for
Ends up shortening the loop, making it easier to read at a glance.

Pick-to: 6.5
Task-number: QTBUG-108875
Change-Id: Ia12a994259b00e9b57f2de48124be9cb38553bf5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-01-17 16:15:11 +01:00
Mårten Nordheim
45717db7a5 Threaded Fortune Example: update example to use qintptr for descriptors
Pick-to: 6.5
Task-number: QTBUG-108875
Change-Id: Ie635a3d2c4c61a59547e8fed0ec84da8538968a3
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-01-17 16:15:11 +01:00
Jan Arve Sæther
0280b7eb96 Painting examples: Don't mix const_iterator and non-const iterators
Reported by Clazy

Pick-to: 6.5
Change-Id: I80fce912b1e5390f0056b1fa9ae0d3cfcf39d045
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-01-17 16:06:08 +01:00
Jan Arve Sæther
1e790fb4db Compile easing curve example with -Weverything
As a consequence, also had to add some suppressions:
-Wno-padded         (this warning should almost never be responded to)
-Wno-c++98-compat   (we want to use c++17 features)
-Wno-weak-vtables   (IMO not worth fixing for an example)

Pick-to: 6.5
Change-Id: I28ae4456c0221ad2370879a691f6343affff138b
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-01-17 13:45:55 +00:00
Volker Hilsheimer
2951f72584 Remove mousebuttons examples
The example didn't show anything useful, and seemed more like a
manual test case.

Pick-to: 6.5
Change-Id: Ia71f39b26943aab04b6895e63b6eed50dd084bfd
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-01-17 06:42:04 +01:00
Jan Arve Sæther
4dbb07f614 Don't use file dialog in the address book example
On small screen devices such as iPhone targets, the save file dialog is
using a non-native dialog, and it doesn't fit the screen real estate to
the extent that the [Ok] button is clipped away.

In addition, the open file dialog and the save file dialog doesn't
cooperate very well on platforms such as iOS without more plumbing.
Since using the file dialog is out of the scope for this example we
remove all usages of it.

Pick-to: 6.5
Change-Id: Ie165355ed0b671d93e44d2d55791156367b0ea5c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-01-13 19:21:44 +00:00
Tor Arne Vestbø
c0967bd288 permissions: Improve error when building example on non-supported platform
Pick-to: 6.5
Change-Id: I02f4fc087d49d21541b1e415db411c09db981278
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-01-10 13:16:03 +01:00
Jaishree Vyas
aae855bd6f Link update for Data Input Output in the save game example
Pick-to: 6.4 6.5
Change-Id: I2a886766d59b9e75f42e401fca9c258fcbe02809
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-01-05 15:22:00 +01:00
Axel Spoerl
f05aee7628 Fix unused variable compiler warning in slider example
The example overrides QWidget::resizeEvent() without using the
QResizeEvent * argument. This results in a compiler warning.

This patch marks the argument unused.

Pick-to: 6.5
Change-Id: I647d0eda7d895e70ed6f232960aec992f5e37b6c
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-01-05 05:21:43 +00:00
Kai Köhne
25c67c608a Examples: Do not wrap custom types in Qt namespace
The Qt namespace should be used for types defined in the Qt library,
not for user types.

Pick-to: 6.5
Change-Id: I6df0ca054888f4a65b19a9cb44324321d1dcfad8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-01-02 23:16:30 +01:00
Andreas Eliasson
b556d6227f Doc: Fix broken link
Also, adjust line length to be < 80 columns and make link
parenthetical.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-107026
Change-Id: I5f7efa5d572103a6fb432d79a52a57363efd9dd7
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2023-01-02 13:50:52 +00:00
Giuseppe D'Angelo
fddeec60cb Wait conditions example: fix an incorrect condition variable usage
3a449bbb69 amended the code to remove
acquiring a lock when waking up a condition variable. It is fine to
not have a lock associated when waking a condition variable; what I
misunderstood was the scope of the lock, which (and this underlines
the importance of commenting _what exactly_ a lock protects, for
each and ever lock) protected both the buffer as well as the counter
of the buffer. This made my reasoning flawed: it is necessary to keep
the lock while notifying, otherwise the counterpart could verify the
condition isn't satisfied and wait (e.g. see numUsedBytes==0), missing
the wake from the other thread (which could arrive between the check and
the wait).

Amends the previous commit.

Change-Id: If7db2d045331f1b33b976fb6bf6aa9117c41678f
Pick-to: 5.15 6.2 6.4 6.5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-12-28 15:10:40 +01:00
Samuel Gaist
253a4a146b examples: port xml examples to new connection style
Task-number: QTBUG-106893
Change-Id: I1cab8949700d7449f0615731c85a77bb9136b0d3
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-21 22:33:02 +01:00
Samuel Gaist
e686a13b7b examples: port network examples to new connection style
Task-number: QTBUG-106893
Change-Id: Id0f558362108fedececb9eede36becc04ff4e307
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-21 21:52:17 +01:00
Samuel Gaist
cf6522e5d7 examples: port qpa examples to new connection style
Task-number: QTBUG-106893
Change-Id: Icf9a40403029c6973167f468f51b2dbdc365a848
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-21 21:52:17 +01:00
Samuel Gaist
d9dd875301 examples: port qmake examples to new connection style
Task-number: QTBUG-106893
Change-Id: Ie4a4874359ac7750de344f4e3702ea7be09e7b53
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-21 22:52:17 +02:00
Samuel Gaist
c47e2aebb6 examples: port embedded examples to new connection style
Task-number: QTBUG-106893
Change-Id: I6d00c53b7747b36c5f0094e566713f13fe74f3de
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-21 21:52:17 +01:00
Eirik Aavitsland
4a5abfcea4 wiggly example: add support for emojis etc. (utf16 surrogate pairs)
The venerable wiggly example was created before unicode support was
added to Qt. Hence, when extracting the individual characters from the
string for painting, the code was not prepared to handle that some
characters, like emojis, are composed of two QChar elements.

Fixes: QTBUG-28853
Change-Id: I9804415f92775e2b78fa9fcaf7a2d112153cdce0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-12 12:33:20 +01:00
Aleksandr Reviakin
83be948833 Remove useless Q_OBJECT in Semaphores example
Fixes: QTBUG-108859
Change-Id: I1acf47b9dfd9c38546a2e965baa74067cedffc4a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-12-07 14:03:03 +01:00
Giuseppe D'Angelo
3a449bbb69 Wait conditions example: code tidies
In no particular order:

* Clean up #includes.

* Document what is protected by the mutex.

* Use explicit, nullptr.

* Use lock managers, not manual calls to lock/unlock.

* Unlock the mutex before notifying the condition variables.

* Condition variables are always meant to be used in a while loop, and
  never with a plain if, because of spurious wakeups.

* Don't lock a mutex just to protect a plain integer. We have atomics
  for that use case.

* Remove an unneeded signal, therefore also the need of using
  Q_OBJECT and the inclusion of the moc-generated file.

Pick-to: 5.15 6.2 6.4
Fixes: QTBUG-108860
Change-Id: I2afc77955b95de8aa5fb88048cd9feb217f83b4f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-06 06:30:55 +01:00
Aleksandr Reviakin
3b0ef74694 Use const reference in loop in JSON Save Game example
Fixes: QTBUG-108857
Change-Id: I503a3c9ebe145d0dae52b74435212807405f0247
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-05 19:02:59 +01:00
Joerg Bornemann
0c5f1beddc CMake: Clean up usage of the examples/widgets/painting/shared lib
Remove conversion artifacts.

Also, remove setting the include path. The library's interface takes
care of that.

Change-Id: Ib5043f15ede2171ab876ccbe603ed0b84de1bce4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-05 15:55:53 +01:00