Commit Graph

1034 Commits

Author SHA1 Message Date
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
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
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
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
Joerg Bornemann
c682d78ac2 CMake: Fix examples/widgets/painting/shared library
This library deliberately links PUBLICly against Qt6::Widgets and
Qt6::OpenGL. Same for the target_include_directories call.

This partially reverts a5de12f0d7.

This fixes the builds of examples using this library.

Change-Id: I2b5791044afc82e71df4a3bbfc26e5b1ab9afa76
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-05 15:55:53 +01:00
Laszlo Agocs
919664b29a Avoid continuous texture alloc in Composition Modes example
There seems to be some confusion from back when the example were
mass-ported to the QOpenGL stuff in Qt 5 times.

Pick-to: 6.4 6.2
Fixes: QTBUG-109119
Change-Id: Ic4bcd010df3fcf82e16385ce241b379f0c351788
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-12-02 20:53:01 +01:00
Tor Arne Vestbø
846cda7eb0 Remove Android High-DPI workarounds in examples
These should no longer be needed for Qt 6.

Change-Id: Ica7214cbf4fc3ddae960309fe89681ec690d28d0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-02 15:53:37 +01:00
Tor Arne Vestbø
465bde54a0 Remove showMaximized() workaround for Android in examples
Android implements QPlatformIntegration::ShowIsMaximized nowadays.

Change-Id: I451a9a8edc8ec407946d44f3e6921c78ac1d11aa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-02 15:53:37 +01:00
Tor Arne Vestbø
5789ffd9cc QErrorMessage: Improve standard dialogs example
Change-Id: Ia5a2251662fe56809fc66cdadd117259d6bfd977
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-11-30 14:48:51 +01:00
Kai Köhne
a5de12f0d7 Examples: Use PRIVATE CMake linkage
We (almost) only build apps, for which PRIVATE linkage makes more sense.

Change-Id: I09a509c3fb33a00cdfdede687b3f95d638f42091
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-11-30 14:48:50 +01:00
Kai Köhne
d221ea609f Examples: Remove duplicated Qt6::PrintSupport link information
Some CMakeLists.txt files did link to Qt6::PrintSupport twice. Also
unify formatting and order of the linker step.

Change-Id: I4af935c5dc3de6c243aad8511b0803ceaa872589
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-11-30 14:48:50 +01:00
Joerg Bornemann
23be657dda Add missing qt_standard_project_setup to richtext/textedit example
This amends commit f562711c64.

Change-Id: Iedfb744aa827c7b246aa05eaadd6bc45639d7b61
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2022-11-28 14:46:03 +01:00
Tor Arne Vestbø
83b31a3d99 Modernize QMessageBox documentation and example
Change-Id: Iebcdf53646f1a42c327414edf21ac93a7d1c0a56
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2022-11-18 19:25:20 +01:00
Kai Köhne
f562711c64 Examples: Use qt_standard_project_setup()
Change-Id: I0ceab08108b7e58e4e2ed25db9e3c289f5c0ddac
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-11-17 19:59:11 +01:00
Kai Köhne
bec264c15f Examples: Use Qt6:: to qualify Qt CMake packages
This is what we promote also in the documentation.

Change-Id: If91aebafe861b0c934acbb2c69afd182abc3345d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-11-17 19:59:11 +01:00
Tor Arne Vestbø
0d517a1352 sharedmemory example: Handle QSharedMemory::AlreadyExists by attaching
Not all platforms clean up the shared memory entries on exit, so the
example needs to handle that case, by attaching instead, as documented.

Change-Id: Ifbcf92d0fad429caf30710bd8a344831cb0d859c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-15 12:27:43 +01:00
Tor Arne Vestbø
c1088d493e QMessageBox: Don't add details button to native dialog helper
The "Show Details..." button is not plumbed in any way to the native
dialog, so when added to a native dialog it will just result in the
dialog being dismissed, instead of revealing any extra content in
the native dialog.

Both the iOS and Android native message dialog implementations add
the details text directly to the dialog, without any action to
explicitly reveal it.

Task-number: QTBUG-108153
Change-Id: I92e00c59b7836f633be44caebd534a47ac58be00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-11 17:48:50 +01:00
Tor Arne Vestbø
b2b941823e Exercise QMessageBox::setInformativeText() in standard dialogs example
Change-Id: Id54a6d93e22fcb6622b434e3766baedb581d6b79
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-03 15:43:58 +01:00
Kai Köhne
b77da049bc Move i18n example to qttools
Move i18n example out of qtbase. In qttools, it can use lrelease,
avoiding the need to store .qm files in the repository.

Change-Id: I8ba36a1372c2a743b809e3f7ea95a67825558f41
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-01 15:52:12 +01:00
Laszlo Papp
faeeb42b85 Add a shortcut editor example
Many applications offer shortcuts for quick interaction with the
application. It is also common in such applications to offer a shortcut
editor in the preferences or separately in a dialog.

However, even though this is a fairly common use case for applications
with more than a couple of shortcuts, there is no good and comprehensive
official Qt example how this could be achieved.

This change is an attempt to bridge the gap.

Change-Id: Ic01a404e6157bda1b0a75a0b792cbfe5d910d48f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2022-10-25 14:38:46 +01:00
YAMAMOTO Atsushi
fe0e76a582 Fix typo in examples/i18n
The name of the variable that handles the qm file is qmlFile.

Change-Id: I873c73cd8f96ff821fe3d2e633e84fef8c687875
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-10-25 10:06:59 +00:00
Marc Mutz
aa37e67ef7 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.

Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-11 23:17:18 +02:00
Eirik Aavitsland
72a3da3d4d Style sheets: add placeholder text color property for edit widgets
The placeholder text was given its own QPalette color role in Qt 5.12,
but there has been no way to specify it from a Qt style sheet.

Fixes: QTBUG-93009
Change-Id: If58ca844c19c65b7eee14c6d5730a4ba27640c33
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-29 08:20:56 +02:00
Friedemann Kleint
33bee95910 Brush up the drop site example
- Use qsizetype
- Use new string literals instead of deprecated QLatin1String()
- Streamline some code
- Remove unused member variable
- Remove module include

Pick-to: 6.4
Change-Id: Ia96424a23f3ae10e57db942de49949ce3aef8876
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-09-21 20:52:14 +02:00
Jan Arve Sæther
30947c7fd4 Pass a parent pointer to the Animation instance to avoid memory leak
The leak is just on termination, but we should show good practices in
our examples

Pick-to: 6.4 6.3 6.2
Change-Id: I39abb7545d3c68a1a537b865ba3fcb5e60c22fbf
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2022-09-15 17:57:54 +02:00
Mikolaj Boc
fc78059934 Use popup() instead of exec() in examples
popup() is generally better but it has a certain advantage that it does
not require a run loop to work, therefore platforms (like WASM) can use
it without resorting to extra measures (like asyncify).

Task-id: QTBUG-106389
Backport-to: 6.4 6.4.0
Change-Id: I87bde677f84048af82cc9aadd982284bdba41e69
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-09-07 21:59:30 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Elias Hautala
1a60194388 Sliders: Add function that changes widgets position on layout
Changes the layout to QGridLayout and adds function to change widgets
position on the layout depending on the windows aspect ratio. Before
this the widgets wouldn't fit on screen when using the example on
Android in portrait.

Fixes: QTCREATORBUG-27685
Pick-to: 6.2 6.3 6.4
Change-Id: I00009cb6c8c250a8333ac3dfa635f70da4576d5e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Jani Korteniemi <jani.korteniemi@qt.io>
2022-08-15 11:22:14 +03:00
Friedemann Kleint
8751ca3dae Polish the model/view tutorial examples
- Reorder the class declarations, moving private sections last
- Make constructors explicit
- Add space to the comments
- Introduce auto
- Replace slot MainWindow::showWindowTitle() by a direct
  connection to slot QWidget::setWindowTitle().

Pick-to: 6.4 6.3
Change-Id: Ic229162434dfef5f2767d0b4e186759ca0f821f3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-08-09 00:19:09 +02:00
Elias Hautala
89ce9a1c5a Basiclayouts: Add scrolling to example
Adds scrolling to basic layouts example because the user interface in
the example doesn't fit properly on smaller screen sizes.

Fixes: QTCREATORBUG-27634
Pick-to: 6.2 6.3 6.4
Change-Id: I61e6eac2b28e5b3ff0f984894fe38167b3f46a9c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Markku Nokkala <markku.nokkala@qt.io>
2022-08-08 17:30:35 +03:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Alexandru Croitor
818a15234c CMake: Make sure qtbase examples are installed into the correct path
The find_package calls need to happen after we set INSTALL_EXAMPLEDIR
to ensure that INSTALL_EXAMPLEDIR is overridden if necessary.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-102879
Change-Id: I3c2e6c5a68a8c6ff9b98b79dbd6c83445d8da052
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-27 16:37:54 +02:00
Kai Köhne
65d9593413 Examples: Use signals, slots instead of Q_SIGNALS, Q_SLOTS
Pick-to: 6.4
Change-Id: I79a352d1bac11edf2d2b0443d2f1bb202fb4e254
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-21 11:24:36 +02:00
Ivan Solovev
7d2361b9da Addressbook example: port to QLatin1StringView
This allows to fix the warning:
 qtbase/examples/widgets/itemviews/addressbook/addresswidget.cpp:115:
  warning: loop variable ‘str’ of type ‘const QString&’ binds to a
  temporary constructed from type ‘const char* const’
  [-Wrange-loop-construct]

Pick-to: 6.4
Change-Id: Ibbfa7f9e85fe9ef79291f9da3d161667286b282e
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-07-15 14:44:38 +02:00
Ivan Solovev
6db91c0df1 GroupBox example: port away from using deprecated QAction::setMenu()
We can achieve the same UI by using QMenu::addMenu() directly

Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: I627f21bc93646943cf6dfbd3b388352b84f73f0f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-14 16:28:49 +02:00
Joerg Bornemann
7ce82225f6 CMake: Let qt6_add_plugin accept sources
The commands qt6_add_executable and qt6_add_library both accept a list
of sources that get automatically added to the created target.
Extend qt6_add_plugin to also accept sources for consistency.

Fixes: QTBUG-104189
Change-Id: Iad5d8c5b31551663be155d068d55e770e1a91b27
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-29 18:32:05 +02:00
Kai Köhne
9d2cc4dd76 Fix typos in docs and comments
Found by codespell

Pick-to: 6.4
Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-15 21:31:02 +02:00
Joni Poikelin
296c3776a8 Remove unnecessary dependency to OpenGL
The example does not use OpenGL in Qt6 anymore so the dependency is not
necessary.

Change-Id: I6189a93eb65bd283ea7e85664582ab0b12a41639
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-30 11:03:19 +03:00
Lucie Gérard
05fc3aef53 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.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
Liang Qi
43b779ab04 examples: add WindowStaysOnBottomHint into preview text
Pick-to: 6.3 6.2 5.15
Change-Id: I1e4e390990fcb6e30b2ff7bb59168e4ffc01a936
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-05-01 21:29:00 +02:00
Sona Kurazyan
908e85cc85 Replace uses of _qs with _s in sources and examples
Task-number: QTBUG-101408
Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-04-19 19:12:20 +02:00
Tang Haixiang
7a7023b7b1 Chip example: fix an accidental bool->int conversion when using PMF connections
The example was refactored to use the PMF connection syntax.
However this introduced a problem: when connecting a QAbstractButton
to a slot that has a default parameter, the semantics of the connection
change between string-based connections and PMF.

Specifically: when connecting the

  QAbstractButton::clicked(bool checked = false)

signal to a slot like

  View::zoomIn(int level = 1)

then a string-based connection like

  connect(button, SIGNAL(clicked()), this, SLOT(zoomIn()))

would call zoomIn without carrying the signal's parameter over.
In other words, zoomIn's parameter is defaulted. The same connection
using PFM instead is

  connect(button, &QAbstractButton::clicked,
          this, &View::zoomIn)

which would "connect" the arguments. This makes emissions that pass
false as clicked's parameter result in a zoomIn by 0.

Fix it by avoiding the default parameter of zoomIn -- just split
the function in two (zoomIn and zoomInBy).

Amends 8cf8122314.

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-100135
Done-with: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Change-Id: I10c150c648034449e3154140108de2d64326d965
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-13 11:36:34 +08:00
Alexandru Croitor
4b7225c662 CMake: Don't build the movie example if the feature is disabled
Pick-to: 6.2 6.3
Fixes: QTBUG-101897
Change-Id: Idef9aaa0c0a0380b88d8769cb19becd613b2173b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-03-19 14:19:13 +01:00
Fabian Kosmale
91a50d8330 Examples: Do not depend on transitive includes
Change-Id: I7bba855a14289edbedbaa07a1234213f59085c1d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-03-17 17:14:38 +01:00
Eirik Aavitsland
51ff94ec92 Avoid using deprecated API in the icons example
Fixes compilation warning.

Fixes: QTBUG-100155
Change-Id: I1af2e69c070497509645c933df58fd42277cfb18
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-02-24 20:17:41 +01:00
Fabian Kosmale
ae7799a924 qtextstream.h: streamline includes
[ChangeLog][Potentially Source-Incompatible Changes] The qtextstream
header no longer includes <QString>, <QStringEncoder> and
<QStringDecoder>. Code which relied on the implicit inclusion of those
classes might now need to include the headers explicitly.

Task-number: QTBUG-97601
Change-Id: Ifb8c8452026195a772c0588dbbbc53fb51cac548
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-10 04:34:13 +01:00
Leena Miettinen
ec57418ecf Doc: Update Notepad tutorial
Update to use Qt Creator 7.0 and CMake as the build system.

Fixes: QTBUG-100075
Pick-to: 6.3
Change-Id: I71e1d1446a2c79c98423ca5d4427b4b4eb00021b
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2022-01-31 14:24:11 +01:00
Kai Köhne
57402ffb9b Examples: Remove unneeded CMake options
CMAKE_INCLUDE_CURRENT_DIR is not necessary anymore for moc since
CMake 3.8: https://cmake.org/cmake/help/latest/release/3.8.html#other-changes

CMAKE_AUTORCC should not be used anymore. Instead, we now use
qt_add_resources() or similar

Enable CMAKE_AUTOUIC only if .ui files are present.

Pick-to: 6.3
Task-number: QTBUG-87643
Change-Id: I835e2994cd5dba9918136999499b9077961b616c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-24 14:00:00 +01:00