summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt4
-rw-r--r--examples/corelib/CMakeLists.txt1
-rw-r--r--examples/corelib/corelib.pro3
-rw-r--r--examples/corelib/ipc/CMakeLists.txt6
-rw-r--r--examples/corelib/mimetypes/CMakeLists.txt2
-rw-r--r--examples/corelib/platform/CMakeLists.txt3
-rw-r--r--examples/corelib/platform/androidnotifier/CMakeLists.txt55
-rw-r--r--examples/corelib/platform/androidnotifier/android/AndroidManifest.xml76
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.pngbin0 -> 3654 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.pngbin0 -> 1432 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.pngbin0 -> 1998 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.pngbin0 -> 4549 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.pngbin0 -> 9275 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.pngbin0 -> 12866 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java93
-rw-r--r--examples/corelib/platform/androidnotifier/androidnotifier.pro20
-rw-r--r--examples/corelib/platform/androidnotifier/doc/images/androidnotifier.pngbin0 -> 48263 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc84
-rw-r--r--examples/corelib/platform/androidnotifier/images/happy.pngbin0 -> 42346 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/images/sad.pngbin0 -> 41223 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/main.cpp103
-rw-r--r--examples/corelib/platform/androidnotifier/main.qrc6
-rw-r--r--examples/corelib/platform/androidnotifier/notificationclient.cpp90
-rw-r--r--examples/corelib/platform/androidnotifier/notificationclient.h76
-rw-r--r--examples/corelib/platform/platform.pro4
-rw-r--r--examples/corelib/serialization/CMakeLists.txt6
-rw-r--r--examples/corelib/threads/CMakeLists.txt8
-rw-r--r--examples/corelib/tools/CMakeLists.txt6
-rw-r--r--examples/dbus/CMakeLists.txt8
-rw-r--r--examples/dbus/remotecontrolledcar/CMakeLists.txt4
-rw-r--r--examples/embedded/CMakeLists.txt12
-rw-r--r--examples/gui/CMakeLists.txt4
-rw-r--r--examples/network/CMakeLists.txt42
-rw-r--r--examples/network/http/CMakeLists.txt10
-rw-r--r--examples/network/http/http.pro4
-rw-r--r--examples/network/http/main.cpp25
-rw-r--r--examples/opengl/CMakeLists.txt26
-rw-r--r--examples/qpa/CMakeLists.txt4
-rw-r--r--examples/qtconcurrent/CMakeLists.txt10
-rw-r--r--examples/qtestlib/CMakeLists.txt10
-rw-r--r--examples/sql/CMakeLists.txt18
-rw-r--r--examples/vulkan/CMakeLists.txt10
-rw-r--r--examples/vulkan/hellovulkancubes/main.cpp14
-rw-r--r--examples/vulkan/hellovulkantexture/main.cpp14
-rw-r--r--examples/vulkan/hellovulkantriangle/main.cpp14
-rw-r--r--examples/vulkan/hellovulkanwidget/main.cpp14
-rw-r--r--examples/vulkan/hellovulkanwindow/main.cpp15
-rw-r--r--examples/widgets/CMakeLists.txt4
-rw-r--r--examples/widgets/animation/CMakeLists.txt2
-rw-r--r--examples/widgets/desktop/CMakeLists.txt4
-rw-r--r--examples/widgets/dialogs/CMakeLists.txt14
-rw-r--r--examples/widgets/doc/images/regularexpression-example.pngbin78860 -> 75203 bytes
-rw-r--r--examples/widgets/doc/src/fetchmore.qdoc17
-rw-r--r--examples/widgets/draganddrop/CMakeLists.txt10
-rw-r--r--examples/widgets/effects/CMakeLists.txt4
-rw-r--r--examples/widgets/gestures/CMakeLists.txt2
-rw-r--r--examples/widgets/graphicsview/CMakeLists.txt22
-rw-r--r--examples/widgets/itemviews/CMakeLists.txt42
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.cpp53
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.h13
-rw-r--r--examples/widgets/itemviews/fetchmore/window.cpp48
-rw-r--r--examples/widgets/itemviews/fetchmore/window.h13
-rw-r--r--examples/widgets/layouts/CMakeLists.txt8
-rw-r--r--examples/widgets/mainwindows/CMakeLists.txt12
-rw-r--r--examples/widgets/painting/CMakeLists.txt24
-rw-r--r--examples/widgets/painting/affine/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/affine/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/composition/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/composition/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/deform/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/deform/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/fontsampler/CMakeLists.txt1
-rw-r--r--examples/widgets/painting/gradients/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/gradients/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp2
-rw-r--r--examples/widgets/painting/pathstroke/.prev_CMakeLists.txt175
-rw-r--r--examples/widgets/painting/pathstroke/CMakeLists.txt177
-rw-r--r--examples/widgets/painting/shared/CMakeLists.txt8
-rw-r--r--examples/widgets/painting/shared/use_lib.cmake13
-rw-r--r--examples/widgets/richtext/CMakeLists.txt8
-rw-r--r--examples/widgets/richtext/textedit/.prev_CMakeLists.txt2
-rw-r--r--examples/widgets/richtext/textedit/CMakeLists.txt2
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textundercolor.pngbin0 -> 6916 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textundercolor.pngbin0 -> 6916 bytes
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp160
-rw-r--r--examples/widgets/richtext/textedit/textedit.h8
-rw-r--r--examples/widgets/richtext/textedit/textedit.qrc2
-rw-r--r--examples/widgets/scroller/CMakeLists.txt2
-rw-r--r--examples/widgets/tools/CMakeLists.txt24
-rw-r--r--examples/widgets/tools/echoplugin/CMakeLists.txt4
-rw-r--r--examples/widgets/tools/plugandpaint/CMakeLists.txt16
-rw-r--r--examples/widgets/tools/plugandpaint/app/CMakeLists.txt56
-rw-r--r--examples/widgets/tools/plugandpaint/app/app.pro6
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt26
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt27
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.cpp114
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.h12
-rw-r--r--examples/widgets/touch/CMakeLists.txt8
-rw-r--r--examples/widgets/tutorials/CMakeLists.txt2
-rw-r--r--examples/widgets/tutorials/addressbook/CMakeLists.txt14
-rw-r--r--examples/widgets/tutorials/gettingStarted/CMakeLists.txt3
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/gettingstartedqt.qdoc7
-rw-r--r--examples/widgets/tutorials/modelview/CMakeLists.txt14
-rw-r--r--examples/widgets/tutorials/notepad/notepad.cpp68
-rw-r--r--examples/widgets/tutorials/notepad/notepad.h12
-rw-r--r--examples/widgets/tutorials/notepad/notepad.ui9
-rw-r--r--examples/widgets/tutorials/widgets/CMakeLists.txt8
-rw-r--r--examples/widgets/widgets/CMakeLists.txt50
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.cpp6
-rw-r--r--examples/xml/CMakeLists.txt10
116 files changed, 1600 insertions, 2120 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index a48879d447..a4fb347ba5 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,6 +1,4 @@
-# Generated from examples.pro.
-
-qt_examples_build_begin()
+qt_examples_build_begin(EXTERNAL_BUILD)
add_subdirectory(corelib)
add_subdirectory(embedded)
diff --git a/examples/corelib/CMakeLists.txt b/examples/corelib/CMakeLists.txt
index 9ec9dcb156..08b44649b7 100644
--- a/examples/corelib/CMakeLists.txt
+++ b/examples/corelib/CMakeLists.txt
@@ -4,6 +4,7 @@ add_subdirectory(ipc)
add_subdirectory(mimetypes)
add_subdirectory(serialization)
add_subdirectory(tools)
+add_subdirectory(platform)
if(QT_FEATURE_thread)
add_subdirectory(threads)
endif()
diff --git a/examples/corelib/corelib.pro b/examples/corelib/corelib.pro
index 8caf2c16df..625957ca1a 100644
--- a/examples/corelib/corelib.pro
+++ b/examples/corelib/corelib.pro
@@ -5,6 +5,7 @@ SUBDIRS = \
ipc \
mimetypes \
serialization \
- tools
+ tools \
+ platform
qtConfig(thread): SUBDIRS += threads
diff --git a/examples/corelib/ipc/CMakeLists.txt b/examples/corelib/ipc/CMakeLists.txt
index 29a8d4f592..214fa4c553 100644
--- a/examples/corelib/ipc/CMakeLists.txt
+++ b/examples/corelib/ipc/CMakeLists.txt
@@ -4,9 +4,9 @@ if(NOT TARGET Qt::Widgets)
return()
endif()
if(QT_FEATURE_sharedmemory)
- add_subdirectory(sharedmemory)
+ qt_internal_add_example(sharedmemory)
endif()
if(QT_FEATURE_localserver AND TARGET Qt::Network)
- add_subdirectory(localfortuneserver)
- add_subdirectory(localfortuneclient)
+ qt_internal_add_example(localfortuneserver)
+ qt_internal_add_example(localfortuneclient)
endif()
diff --git a/examples/corelib/mimetypes/CMakeLists.txt b/examples/corelib/mimetypes/CMakeLists.txt
index ac06659362..3124006aaa 100644
--- a/examples/corelib/mimetypes/CMakeLists.txt
+++ b/examples/corelib/mimetypes/CMakeLists.txt
@@ -1,5 +1,5 @@
# Generated from mimetypes.pro.
if(TARGET Qt::Widgets)
- add_subdirectory(mimetypebrowser)
+ qt_internal_add_example(mimetypebrowser)
endif()
diff --git a/examples/corelib/platform/CMakeLists.txt b/examples/corelib/platform/CMakeLists.txt
new file mode 100644
index 0000000000..1a10578a1f
--- /dev/null
+++ b/examples/corelib/platform/CMakeLists.txt
@@ -0,0 +1,3 @@
+if(ANDROID)
+ add_subdirectory(androidnotifier)
+endif()
diff --git a/examples/corelib/platform/androidnotifier/CMakeLists.txt b/examples/corelib/platform/androidnotifier/CMakeLists.txt
new file mode 100644
index 0000000000..1dca63faf2
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/CMakeLists.txt
@@ -0,0 +1,55 @@
+cmake_minimum_required(VERSION 3.14)
+project(androidnotifier LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
+find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/platform/androidnotifier")
+
+set(PROJECT_SOURCES
+ main.cpp
+ notificationclient.cpp
+ notificationclient.h
+)
+
+if(ANDROID)
+ qt_add_executable(androidnotifier
+ MANUAL_FINALIZATION
+ ${PROJECT_SOURCES})
+ target_link_libraries(androidnotifier PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
+
+ set_property(TARGET androidnotifier APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
+ ${CMAKE_CURRENT_SOURCE_DIR}/android)
+
+ if(QT_VERSION_MAJOR EQUAL 6)
+ qt_finalize_executable(androidnotifier)
+ endif()
+
+ set(qml_resource_files
+ "images/happy.png"
+ "images/sad.png"
+ )
+
+ qt6_add_resources(androidnotifier "main"
+ PREFIX
+ "/"
+ FILES
+ ${qml_resource_files}
+ )
+
+ install(TARGETS androidnotifier
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ )
+endif()
diff --git a/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml b/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml
new file mode 100644
index 0000000000..d53be9b3f3
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<manifest package="org.qtproject.example.androidnotifier" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
+
+ <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
+ Remove the comment if you do not require these default permissions. -->
+ <!-- %%INSERT_PERMISSIONS -->
+
+ <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
+ Remove the comment if you do not require these default features. -->
+ <!-- %%INSERT_FEATURES -->
+
+ <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
+
+ <application android:hardwareAccelerated="true" android:name="org.qtproject.qt.android.bindings.QtApplication" android:label="Qt Notifier" android:extractNativeLibs="true" android:icon="@drawable/icon">
+ <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ <!-- Application arguments -->
+ <!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
+ <!-- Application arguments -->
+ <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
+ <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
+ <meta-data android:name="android.app.repository" android:value="default"/>
+ <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
+ <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
+ <!-- Deploy Qt libs as part of package -->
+ <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
+ <!-- Run with local libs -->
+ <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
+ <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
+ <meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
+ <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
+ <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
+ <!-- Used to specify custom system library path to run with local system libs -->
+ <!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
+ <!-- Messages maps -->
+ <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
+ <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
+ <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
+ <meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
+ <!-- Messages maps -->
+ <!-- Splash screen -->
+ <!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
+ then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
+ use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
+ are done populating your window with content. -->
+ <!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
+ <!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
+ <!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
+ <!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
+ <!-- Splash screen -->
+ <!-- Background running -->
+ <!-- Warning: changing this value to true may cause unexpected crashes if the
+ application still try to draw after
+ "applicationStateChanged(Qt::ApplicationSuspended)"
+ signal is sent! -->
+ <meta-data android:name="android.app.background_running" android:value="false"/>
+ <!-- Background running -->
+ <!-- auto screen scale factor -->
+ <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
+ <!-- auto screen scale factor -->
+ <!-- extract android style -->
+ <!-- available android:values :
+ * default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
+ * full - useful QWidget & Quick Controls 1 apps
+ * minimal - useful for Quick Controls 2 apps, it is much faster than "full"
+ * none - useful for apps that don't use any of the above Qt modules
+ -->
+ <meta-data android:name="android.app.extract_android_style" android:value="none"/>
+ <!-- extract android style -->
+ </activity>
+ <!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
+ </application>
+</manifest>
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000000..d3ccebe1f2
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000000..2194be145e
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000000..31812ccdd9
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.png
new file mode 100644
index 0000000000..3aeae642d9
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.png
new file mode 100644
index 0000000000..f754fd18ae
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.png
new file mode 100644
index 0000000000..d0d043bf9c
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java b/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java
new file mode 100644
index 0000000000..c43513b17a
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+package org.qtproject.example.androidnotifier;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.BitmapFactory;
+import android.app.NotificationChannel;
+
+public class NotificationClient
+{
+ public static void notify(Context context, String message) {
+ try {
+ NotificationManager m_notificationManager = (NotificationManager)
+ context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ Notification.Builder m_builder;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+ int importance = NotificationManager.IMPORTANCE_DEFAULT;
+ NotificationChannel notificationChannel;
+ notificationChannel = new NotificationChannel("Qt", "Qt Notifier", importance);
+ m_notificationManager.createNotificationChannel(notificationChannel);
+ m_builder = new Notification.Builder(context, notificationChannel.getId());
+ } else {
+ m_builder = new Notification.Builder(context);
+ }
+
+ Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
+ m_builder.setSmallIcon(R.drawable.icon)
+ .setLargeIcon(icon)
+ .setContentTitle("A message from Qt!")
+ .setContentText(message)
+ .setDefaults(Notification.DEFAULT_SOUND)
+ .setColor(Color.GREEN)
+ .setAutoCancel(true);
+
+ m_notificationManager.notify(0, m_builder.build());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/examples/corelib/platform/androidnotifier/androidnotifier.pro b/examples/corelib/platform/androidnotifier/androidnotifier.pro
new file mode 100644
index 0000000000..f1650c1911
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/androidnotifier.pro
@@ -0,0 +1,20 @@
+QT += core gui
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+SOURCES += \
+ main.cpp \
+ notificationclient.cpp
+
+HEADERS += \
+ notificationclient.h
+
+RESOURCES += \
+ main.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/corelib/platform/androidnotifier
+INSTALLS += target
+
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
+OTHER_FILES += \
+ android/src/org/qtproject/example/androidnotifier/NotificationClient.java \
+ android/AndroidManifest.xml
diff --git a/examples/corelib/platform/androidnotifier/doc/images/androidnotifier.png b/examples/corelib/platform/androidnotifier/doc/images/androidnotifier.png
new file mode 100644
index 0000000000..36a4a50c47
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/doc/images/androidnotifier.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc b/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc
new file mode 100644
index 0000000000..b1e4243d56
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title Qt Android Notifier
+ \example platform/androidnotifier
+ \brief Demonstrates calling Java code from Qt in an Android application.
+
+ \image androidnotifier.png
+
+ This example demonstrates how to add a custom Java class to an Android
+ application, and how to call it using the JNI convenience APIs in Qt.
+
+ Click on one of the smiley faces to send a notification in the status bar
+ of the Android screen.
+
+ \include examples-run.qdocinc
+
+ \section1 Calling Java Methods from C++ Code
+
+ We define a custom Java class called \c NotificationClient in the
+ NotificationClient.java file:
+
+ \quotefromfile platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java
+ \skipto org.qtproject.example.androidnotifier
+ \printuntil /^\}/
+
+ In the NotificationClient C++ class header file, \c notificationclient.h, we
+ declare a simple C++ API to display notifications on an Android device. It
+ consists of a single string property, \c notification, and a slot,
+ \c updateAndroidNotification(), that calls the Java code:
+
+ \snippet platform/androidnotifier/notificationclient.h Qt Notification Class
+
+ We connect the \c notificationChanged() signal to the
+ \c updateAndroidNotification() slot to update the notification text when the
+ \c notification text changes:
+
+ \snippet platform/androidnotifier/notificationclient.cpp notification changed signal
+
+ The \c updateAndroidNotification() function calls the Java method responsible
+ for sending the notification from the Android platform APIs. First, we construct
+ a Java string \c jstring from the notification string, then pass the \c jstring
+ object as a parameter to the \c notify() method in Java:
+
+ \snippet platform/androidnotifier/notificationclient.cpp Send notification message to Java
+
+ The call to the Java meethod use \l QJniObject which relies on the Java Native
+ Interface (JNI) APIs to communicate with Java. Also, in the previous snippet,
+ we are passing the app's context object which the the static Java code can use
+ to tap into the app's specific properties and APIs.
+
+ To make sure our smiley buttons do what they are supposed to, we add the
+ the following code to change the notification text if either of them are
+ clicked:
+
+ \snippet platform/androidnotifier/main.cpp Connect button signals
+
+ \sa {Qt for Android}
+*/
diff --git a/examples/corelib/platform/androidnotifier/images/happy.png b/examples/corelib/platform/androidnotifier/images/happy.png
new file mode 100644
index 0000000000..af9412c2fb
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/images/happy.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/images/sad.png b/examples/corelib/platform/androidnotifier/images/sad.png
new file mode 100644
index 0000000000..928184b413
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/images/sad.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/main.cpp b/examples/corelib/platform/androidnotifier/main.cpp
new file mode 100644
index 0000000000..8b2e937351
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/main.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "notificationclient.h"
+
+#include <QApplication>
+#include <QWidget>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QFont>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ QWidget widget;
+ QPushButton happyButton;
+ happyButton.setIcon(QIcon(":/images/happy.png"));
+ happyButton.setIconSize(QSize(happyButton.width(), 120));
+
+ QPushButton sadButton;
+ sadButton.setIcon(QIcon(":/images/sad.png"));
+ sadButton.setIconSize(QSize(sadButton.width(), 120));
+
+ QVBoxLayout mainLayout;
+ QHBoxLayout labelLayout;
+ QLabel label = QLabel("Click a smiley to notify your mood");
+ QFont font = label.font();
+ font.setPointSize(20);
+ label.setFont(font);
+ labelLayout.addWidget(&label);
+ labelLayout.setAlignment(Qt::AlignHCenter);
+ mainLayout.addLayout(&labelLayout);
+
+ QHBoxLayout smileysLayout;
+ smileysLayout.addWidget(&sadButton);
+ smileysLayout.addWidget(&happyButton);
+ smileysLayout.setAlignment(Qt::AlignCenter);
+ mainLayout.addLayout(&smileysLayout);
+ widget.setLayout(&mainLayout);
+
+//! [Connect button signals]
+ QObject::connect(&happyButton, &QPushButton::clicked, []() {
+ NotificationClient().setNotification("The user is happy!");
+ });
+
+ QObject::connect(&sadButton, &QPushButton::clicked, []() {
+ NotificationClient().setNotification("The user is sad!");
+ });
+//! [Connect button signals]
+
+ widget.show();
+ return a.exec();
+}
+
diff --git a/examples/corelib/platform/androidnotifier/main.qrc b/examples/corelib/platform/androidnotifier/main.qrc
new file mode 100644
index 0000000000..e0bb052fd2
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/main.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/happy.png</file>
+ <file>images/sad.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/corelib/platform/androidnotifier/notificationclient.cpp b/examples/corelib/platform/androidnotifier/notificationclient.cpp
new file mode 100644
index 0000000000..b2093234b9
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/notificationclient.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "notificationclient.h"
+
+#include <QtCore/qjniobject.h>
+#include <QtCore/qcoreapplication.h>
+
+NotificationClient::NotificationClient(QObject *parent)
+ : QObject(parent)
+{
+ connect(this, &NotificationClient::notificationChanged,
+ this, &NotificationClient::updateAndroidNotification);
+}
+
+void NotificationClient::setNotification(const QString &notification)
+{
+ if (m_notification == notification)
+ return;
+
+//! [notification changed signal]
+ m_notification = notification;
+ emit notificationChanged();
+//! [notification changed signal]
+}
+
+QString NotificationClient::notification() const
+{
+ return m_notification;
+}
+
+//! [Send notification message to Java]
+void NotificationClient::updateAndroidNotification()
+{
+ QJniObject javaNotification = QJniObject::fromString(m_notification);
+ QJniObject::callStaticMethod<void>(
+ "org/qtproject/example/androidnotifier/NotificationClient",
+ "notify",
+ "(Landroid/content/Context;Ljava/lang/String;)V",
+ QNativeInterface::QAndroidApplication::context(),
+ javaNotification.object<jstring>());
+}
+//! [Send notification message to Java]
diff --git a/examples/corelib/platform/androidnotifier/notificationclient.h b/examples/corelib/platform/androidnotifier/notificationclient.h
new file mode 100644
index 0000000000..f821dbfc8d
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/notificationclient.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOTIFICATIONCLIENT_H
+#define NOTIFICATIONCLIENT_H
+
+#include <QObject>
+
+//! [Qt Notification Class]
+class NotificationClient : public QObject
+{
+ Q_OBJECT
+public:
+ explicit NotificationClient(QObject *parent = 0);
+
+ void setNotification(const QString &notification);
+ QString notification() const;
+
+signals:
+ void notificationChanged();
+
+private slots:
+ void updateAndroidNotification();
+
+private:
+ QString m_notification;
+};
+//! [Qt Notification Class]
+#endif // NOTIFICATIONCLIENT_H
diff --git a/examples/corelib/platform/platform.pro b/examples/corelib/platform/platform.pro
new file mode 100644
index 0000000000..b9e58c7c7e
--- /dev/null
+++ b/examples/corelib/platform/platform.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+CONFIG += no_docs_target
+
+android: SUBDIRS += androidnotifier
diff --git a/examples/corelib/serialization/CMakeLists.txt b/examples/corelib/serialization/CMakeLists.txt
index a64b5130d2..486f5d0c14 100644
--- a/examples/corelib/serialization/CMakeLists.txt
+++ b/examples/corelib/serialization/CMakeLists.txt
@@ -1,5 +1,5 @@
# Generated from serialization.pro.
-add_subdirectory(cbordump)
-add_subdirectory(convert)
-add_subdirectory(savegame)
+qt_internal_add_example(cbordump)
+qt_internal_add_example(convert)
+qt_internal_add_example(savegame)
diff --git a/examples/corelib/threads/CMakeLists.txt b/examples/corelib/threads/CMakeLists.txt
index f84700fdb4..848880d076 100644
--- a/examples/corelib/threads/CMakeLists.txt
+++ b/examples/corelib/threads/CMakeLists.txt
@@ -1,8 +1,8 @@
# Generated from threads.pro.
-add_subdirectory(semaphores)
-add_subdirectory(waitconditions)
+qt_internal_add_example(semaphores)
+qt_internal_add_example(waitconditions)
if(TARGET Qt::Widgets)
- add_subdirectory(mandelbrot)
- add_subdirectory(queuedcustomtype)
+ qt_internal_add_example(mandelbrot)
+ qt_internal_add_example(queuedcustomtype)
endif()
diff --git a/examples/corelib/tools/CMakeLists.txt b/examples/corelib/tools/CMakeLists.txt
index a9f82dfab5..27e7699f26 100644
--- a/examples/corelib/tools/CMakeLists.txt
+++ b/examples/corelib/tools/CMakeLists.txt
@@ -3,6 +3,6 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(contiguouscache)
-add_subdirectory(customtype)
-add_subdirectory(customtypesending)
+qt_internal_add_example(contiguouscache)
+qt_internal_add_example(customtype)
+qt_internal_add_example(customtypesending)
diff --git a/examples/dbus/CMakeLists.txt b/examples/dbus/CMakeLists.txt
index 065cc76022..ac941a3218 100644
--- a/examples/dbus/CMakeLists.txt
+++ b/examples/dbus/CMakeLists.txt
@@ -3,12 +3,12 @@
if(NOT TARGET Qt::DBus)
return()
endif()
-add_subdirectory(listnames)
-add_subdirectory(pingpong)
+qt_internal_add_example(listnames)
+qt_internal_add_example(pingpong)
if(QT_FEATURE_process)
- add_subdirectory(complexpingpong)
+ qt_internal_add_example(complexpingpong)
endif()
if(TARGET Qt::Widgets)
- add_subdirectory(chat)
+ qt_internal_add_example(chat)
add_subdirectory(remotecontrolledcar)
endif()
diff --git a/examples/dbus/remotecontrolledcar/CMakeLists.txt b/examples/dbus/remotecontrolledcar/CMakeLists.txt
index 4d41919962..86f9f03ccc 100644
--- a/examples/dbus/remotecontrolledcar/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from remotecontrolledcar.pro.
-add_subdirectory(car)
-add_subdirectory(controller)
+qt_internal_add_example(car)
+qt_internal_add_example(controller)
diff --git a/examples/embedded/CMakeLists.txt b/examples/embedded/CMakeLists.txt
index 84292edccc..5f4bcc5628 100644
--- a/examples/embedded/CMakeLists.txt
+++ b/examples/embedded/CMakeLists.txt
@@ -3,9 +3,9 @@
if(NOT TARGET Qt::Gui OR (NOT embedded AND NOT x11))
return()
endif()
-add_subdirectory(styleexample)
-add_subdirectory(raycasting)
-add_subdirectory(flickable)
-add_subdirectory(digiflip)
-add_subdirectory(lightmaps)
-add_subdirectory(flightinfo)
+qt_internal_add_example(styleexample)
+qt_internal_add_example(raycasting)
+qt_internal_add_example(flickable)
+qt_internal_add_example(digiflip)
+qt_internal_add_example(lightmaps)
+qt_internal_add_example(flightinfo)
diff --git a/examples/gui/CMakeLists.txt b/examples/gui/CMakeLists.txt
index 7631777ef4..d952899f55 100644
--- a/examples/gui/CMakeLists.txt
+++ b/examples/gui/CMakeLists.txt
@@ -3,5 +3,5 @@
if(NOT TARGET Qt::Gui)
return()
endif()
-add_subdirectory(analogclock)
-add_subdirectory(rasterwindow)
+qt_internal_add_example(analogclock)
+qt_internal_add_example(rasterwindow)
diff --git a/examples/network/CMakeLists.txt b/examples/network/CMakeLists.txt
index c28c951b69..fd61e75aef 100644
--- a/examples/network/CMakeLists.txt
+++ b/examples/network/CMakeLists.txt
@@ -3,36 +3,36 @@
if(NOT TARGET Qt::Network)
return()
endif()
-add_subdirectory(download)
-add_subdirectory(downloadmanager)
+qt_internal_add_example(download)
+qt_internal_add_example(downloadmanager)
if(NOT INTEGRITY)
- add_subdirectory(dnslookup)
+ qt_internal_add_example(dnslookup)
endif()
if(TARGET Qt::Widgets)
- add_subdirectory(blockingfortuneclient)
- add_subdirectory(broadcastreceiver)
- add_subdirectory(broadcastsender)
- add_subdirectory(http)
- add_subdirectory(loopback)
- add_subdirectory(threadedfortuneserver)
- add_subdirectory(googlesuggest)
- add_subdirectory(torrent)
- add_subdirectory(multicastreceiver)
- add_subdirectory(multicastsender)
- add_subdirectory(fortuneclient)
- add_subdirectory(fortuneserver)
+ qt_internal_add_example(blockingfortuneclient)
+ qt_internal_add_example(broadcastreceiver)
+ qt_internal_add_example(broadcastsender)
+ qt_internal_add_example(http)
+ qt_internal_add_example(loopback)
+ qt_internal_add_example(threadedfortuneserver)
+ qt_internal_add_example(googlesuggest)
+ qt_internal_add_example(torrent)
+ qt_internal_add_example(multicastreceiver)
+ qt_internal_add_example(multicastsender)
+ qt_internal_add_example(fortuneclient)
+ qt_internal_add_example(fortuneserver)
endif()
if(QT_FEATURE_processenvironment AND TARGET Qt::Widgets)
- add_subdirectory(network-chat)
+ qt_internal_add_example(network-chat)
endif()
if(QT_FEATURE_ssl AND TARGET Qt::Widgets)
- add_subdirectory(securesocketclient)
+ qt_internal_add_example(securesocketclient)
endif()
if(QT_FEATURE_dtls AND TARGET Qt::Widgets)
- add_subdirectory(secureudpserver)
- add_subdirectory(secureudpclient)
+ qt_internal_add_example(secureudpserver)
+ qt_internal_add_example(secureudpclient)
endif()
if(QT_FEATURE_sctp AND TARGET Qt::Widgets)
- add_subdirectory(multistreamserver)
- add_subdirectory(multistreamclient)
+ qt_internal_add_example(multistreamserver)
+ qt_internal_add_example(multistreamclient)
endif()
diff --git a/examples/network/http/CMakeLists.txt b/examples/network/http/CMakeLists.txt
index b967881c6a..aaa72982fb 100644
--- a/examples/network/http/CMakeLists.txt
+++ b/examples/network/http/CMakeLists.txt
@@ -36,16 +36,6 @@ target_link_libraries(http PUBLIC
Qt::Widgets
)
-if(ANDROID AND TARGET Qt::AndroidExtras)
- target_compile_definitions(http PUBLIC
- REQUEST_PERMISSIONS_ON_ANDROID
- )
-
- target_link_libraries(http PUBLIC
- Qt::AndroidExtras
- )
-endif()
-
install(TARGETS http
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/network/http/http.pro b/examples/network/http/http.pro
index f67cd01495..2f2d3b00ae 100644
--- a/examples/network/http/http.pro
+++ b/examples/network/http/http.pro
@@ -1,8 +1,4 @@
QT += network widgets
-android: qtHaveModule(androidextras) {
- QT += androidextras
- DEFINES += REQUEST_PERMISSIONS_ON_ANDROID
-}
HEADERS += httpwindow.h
SOURCES += httpwindow.cpp \
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp
index 6c86933fd6..94c3685af8 100644
--- a/examples/network/http/main.cpp
+++ b/examples/network/http/main.cpp
@@ -53,30 +53,17 @@
#include <QScreen>
#include "httpwindow.h"
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
-#include <QtAndroid>
-
-bool requestStoragePermission() {
- using namespace QtAndroid;
-
- QString permission = QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE");
- const QHash<QString, PermissionResult> results = requestPermissionsSync(QStringList({permission}));
- if (!results.contains(permission) || results[permission] == PermissionResult::Denied) {
- qWarning() << "Couldn't get permission: " << permission;
- return false;
- }
-
- return true;
-}
-#endif
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
- if (!requestStoragePermission())
+
+ auto permission = QPermission::WriteStorage;
+ if (QCoreApplication::requestPermission(permission).result() != QPermission::Authorized) {
+ qWarning() << "Couldn't get 'WriteStorage' permission!";
return -1;
-#endif
+ }
+
HttpWindow httpWin;
const QRect availableSize = httpWin.screen()->availableGeometry();
httpWin.resize(availableSize.width() / 5, availableSize.height() / 5);
diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt
index 3d5b055b1a..af1792edd0 100644
--- a/examples/opengl/CMakeLists.txt
+++ b/examples/opengl/CMakeLists.txt
@@ -1,17 +1,17 @@
# Generated from opengl.pro.
-add_subdirectory(hellowindow)
-add_subdirectory(paintedwindow)
-add_subdirectory(openglwindow)
-add_subdirectory(qopenglwindow)
+qt_internal_add_example(hellowindow)
+qt_internal_add_example(paintedwindow)
+qt_internal_add_example(openglwindow)
+qt_internal_add_example(qopenglwindow)
if(TARGET Qt::Widgets)
- add_subdirectory(contextinfo)
- add_subdirectory(threadedqopenglwidget)
- add_subdirectory(2dpainting)
- add_subdirectory(hellogl2)
- add_subdirectory(qopenglwidget)
- add_subdirectory(cube)
- add_subdirectory(textures)
- add_subdirectory(hellogles3)
- add_subdirectory(computegles31)
+ qt_internal_add_example(contextinfo)
+ qt_internal_add_example(threadedqopenglwidget)
+ qt_internal_add_example(2dpainting)
+ qt_internal_add_example(hellogl2)
+ qt_internal_add_example(qopenglwidget)
+ qt_internal_add_example(cube)
+ qt_internal_add_example(textures)
+ qt_internal_add_example(hellogles3)
+ qt_internal_add_example(computegles31)
endif()
diff --git a/examples/qpa/CMakeLists.txt b/examples/qpa/CMakeLists.txt
index 6768aa052d..a5043f2407 100644
--- a/examples/qpa/CMakeLists.txt
+++ b/examples/qpa/CMakeLists.txt
@@ -3,5 +3,5 @@
if(NOT TARGET Qt::Gui)
return()
endif()
-add_subdirectory(windows)
-add_subdirectory(qrasterwindow)
+qt_internal_add_example(windows)
+qt_internal_add_example(qrasterwindow)
diff --git a/examples/qtconcurrent/CMakeLists.txt b/examples/qtconcurrent/CMakeLists.txt
index ed1be7ec4d..0cf2bee39c 100644
--- a/examples/qtconcurrent/CMakeLists.txt
+++ b/examples/qtconcurrent/CMakeLists.txt
@@ -4,11 +4,11 @@ if(NOT TARGET Qt::Concurrent)
return()
endif()
if(TARGET Qt::Widgets)
- add_subdirectory(imagescaling)
- add_subdirectory(progressdialog)
- add_subdirectory(runfunction)
- add_subdirectory(wordcount)
+ qt_internal_add_example(imagescaling)
+ qt_internal_add_example(progressdialog)
+ qt_internal_add_example(runfunction)
+ qt_internal_add_example(wordcount)
endif()
if(TARGET Qt::Gui)
- add_subdirectory(map)
+ qt_internal_add_example(map)
endif()
diff --git a/examples/qtestlib/CMakeLists.txt b/examples/qtestlib/CMakeLists.txt
index a3ffcd2481..84fd46acf9 100644
--- a/examples/qtestlib/CMakeLists.txt
+++ b/examples/qtestlib/CMakeLists.txt
@@ -3,8 +3,8 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(tutorial1)
-add_subdirectory(tutorial2)
-add_subdirectory(tutorial3)
-add_subdirectory(tutorial4)
-add_subdirectory(tutorial5)
+qt_internal_add_example(tutorial1)
+qt_internal_add_example(tutorial2)
+qt_internal_add_example(tutorial3)
+qt_internal_add_example(tutorial4)
+qt_internal_add_example(tutorial5)
diff --git a/examples/sql/CMakeLists.txt b/examples/sql/CMakeLists.txt
index e54fc0860f..b45fd6f7cc 100644
--- a/examples/sql/CMakeLists.txt
+++ b/examples/sql/CMakeLists.txt
@@ -3,17 +3,17 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(books)
-add_subdirectory(drilldown)
-add_subdirectory(cachedtable)
-add_subdirectory(querymodel)
-add_subdirectory(relationaltablemodel)
-add_subdirectory(sqlwidgetmapper)
-add_subdirectory(tablemodel)
+qt_internal_add_example(books)
+qt_internal_add_example(drilldown)
+qt_internal_add_example(cachedtable)
+qt_internal_add_example(querymodel)
+qt_internal_add_example(relationaltablemodel)
+qt_internal_add_example(sqlwidgetmapper)
+qt_internal_add_example(tablemodel)
if(TARGET Qt::Xml)
- add_subdirectory(masterdetail)
+ qt_internal_add_example(masterdetail)
endif()
if(NOT CMAKE_CROSSCOMPILING) # special case
- add_subdirectory(sqlbrowser)
+ qt_internal_add_example(sqlbrowser)
endif()
diff --git a/examples/vulkan/CMakeLists.txt b/examples/vulkan/CMakeLists.txt
index b00a40447a..2320faaeb3 100644
--- a/examples/vulkan/CMakeLists.txt
+++ b/examples/vulkan/CMakeLists.txt
@@ -1,11 +1,11 @@
# Generated from vulkan.pro.
-add_subdirectory(hellovulkanwindow)
-add_subdirectory(hellovulkantriangle)
-add_subdirectory(hellovulkantexture)
+qt_internal_add_example(hellovulkanwindow)
+qt_internal_add_example(hellovulkantriangle)
+qt_internal_add_example(hellovulkantexture)
if(TARGET Qt::Widgets)
- add_subdirectory(hellovulkanwidget)
+ qt_internal_add_example(hellovulkanwidget)
endif()
if(TARGET Qt::Concurrent AND TARGET Qt::Widgets)
- add_subdirectory(hellovulkancubes)
+ qt_internal_add_example(hellovulkancubes)
endif()
diff --git a/examples/vulkan/hellovulkancubes/main.cpp b/examples/vulkan/hellovulkancubes/main.cpp
index 4ec4d48645..9c5244bbdf 100644
--- a/examples/vulkan/hellovulkancubes/main.cpp
+++ b/examples/vulkan/hellovulkancubes/main.cpp
@@ -63,19 +63,7 @@ int main(int argc, char **argv)
if (dbg) {
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
}
if (!inst.create())
diff --git a/examples/vulkan/hellovulkantexture/main.cpp b/examples/vulkan/hellovulkantexture/main.cpp
index bb6103e9cf..86414dd0a1 100644
--- a/examples/vulkan/hellovulkantexture/main.cpp
+++ b/examples/vulkan/hellovulkantexture/main.cpp
@@ -62,19 +62,7 @@ int main(int argc, char *argv[])
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
diff --git a/examples/vulkan/hellovulkantriangle/main.cpp b/examples/vulkan/hellovulkantriangle/main.cpp
index d3eef2e14a..ae56207f81 100644
--- a/examples/vulkan/hellovulkantriangle/main.cpp
+++ b/examples/vulkan/hellovulkantriangle/main.cpp
@@ -73,19 +73,7 @@ int main(int argc, char *argv[])
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
diff --git a/examples/vulkan/hellovulkanwidget/main.cpp b/examples/vulkan/hellovulkanwidget/main.cpp
index 5ddaf90224..999011db5f 100644
--- a/examples/vulkan/hellovulkanwidget/main.cpp
+++ b/examples/vulkan/hellovulkanwidget/main.cpp
@@ -81,19 +81,7 @@ int main(int argc, char *argv[])
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
diff --git a/examples/vulkan/hellovulkanwindow/main.cpp b/examples/vulkan/hellovulkanwindow/main.cpp
index 313c28f9e0..72e80cdd13 100644
--- a/examples/vulkan/hellovulkanwindow/main.cpp
+++ b/examples/vulkan/hellovulkanwindow/main.cpp
@@ -63,20 +63,7 @@ int main(int argc, char *argv[])
//! [0]
QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
-
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
//! [0]
diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt
index 5026a40a80..753e3b8499 100644
--- a/examples/widgets/CMakeLists.txt
+++ b/examples/widgets/CMakeLists.txt
@@ -9,7 +9,7 @@ endif()
add_subdirectory(desktop)
add_subdirectory(dialogs)
add_subdirectory(effects)
-add_subdirectory(gallery)
+qt_internal_add_example(gallery)
add_subdirectory(gestures)
add_subdirectory(graphicsview)
add_subdirectory(itemviews)
@@ -28,5 +28,5 @@ if(QT_FEATURE_cursor) # special case
add_subdirectory(mainwindows)
endif()
if(QT_FEATURE_opengl AND TARGET Qt::Gui)
- add_subdirectory(windowcontainer)
+ qt_internal_add_example(windowcontainer)
endif()
diff --git a/examples/widgets/animation/CMakeLists.txt b/examples/widgets/animation/CMakeLists.txt
index e3382787aa..70f484a778 100644
--- a/examples/widgets/animation/CMakeLists.txt
+++ b/examples/widgets/animation/CMakeLists.txt
@@ -1,3 +1,3 @@
# Generated from animation.pro.
-add_subdirectory(easing)
+qt_internal_add_example(easing)
diff --git a/examples/widgets/desktop/CMakeLists.txt b/examples/widgets/desktop/CMakeLists.txt
index a50d3c2f0a..b317205c43 100644
--- a/examples/widgets/desktop/CMakeLists.txt
+++ b/examples/widgets/desktop/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from desktop.pro.
-add_subdirectory(screenshot)
-add_subdirectory(systray)
+qt_internal_add_example(screenshot)
+qt_internal_add_example(systray)
diff --git a/examples/widgets/dialogs/CMakeLists.txt b/examples/widgets/dialogs/CMakeLists.txt
index 354424bf1f..32f8bc29a8 100644
--- a/examples/widgets/dialogs/CMakeLists.txt
+++ b/examples/widgets/dialogs/CMakeLists.txt
@@ -1,13 +1,13 @@
# Generated from dialogs.pro.
if(QT_FEATURE_wizard)
- add_subdirectory(classwizard)
- add_subdirectory(trivialwizard)
+ qt_internal_add_example(classwizard)
+ qt_internal_add_example(trivialwizard)
endif()
-add_subdirectory(extension)
-add_subdirectory(findfiles)
-add_subdirectory(standarddialogs)
-add_subdirectory(tabdialog)
+qt_internal_add_example(extension)
+qt_internal_add_example(findfiles)
+qt_internal_add_example(standarddialogs)
+qt_internal_add_example(tabdialog)
if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport)
- add_subdirectory(licensewizard)
+ qt_internal_add_example(licensewizard)
endif()
diff --git a/examples/widgets/doc/images/regularexpression-example.png b/examples/widgets/doc/images/regularexpression-example.png
index d426d8514a..ac314a7748 100644
--- a/examples/widgets/doc/images/regularexpression-example.png
+++ b/examples/widgets/doc/images/regularexpression-example.png
Binary files differ
diff --git a/examples/widgets/doc/src/fetchmore.qdoc b/examples/widgets/doc/src/fetchmore.qdoc
index a27efaf071..940a252319 100644
--- a/examples/widgets/doc/src/fetchmore.qdoc
+++ b/examples/widgets/doc/src/fetchmore.qdoc
@@ -34,15 +34,9 @@
\image fetchmore-example.png
-
- This example consists of a dialog where you can enter a directory
- name in the \uicontrol Directory edit field. The application loads and
- visualizes all files it finds as you are typing. It is not required
- to press [Enter] to launch the search.
-
When you have large - or perhaps even infinite - data sets, you
will need to add items to the model in batches, and preferably only
- when the items are needed by the view (i.e., when they are visible
+ when the items are needed by the view (i.e., when they become visible
in the view).
In this example, we implement \c FileListModel - an item view
@@ -50,6 +44,15 @@
Window, which sets up the GUI and feeds the model with
directories.
+ The UI consists of a dialog with a list showing the contents
+ of the root directory. Directories can be navigated by double-clicking.
+
+ At the bottom, there is a log window displaying messages when the view
+ asks the model for more data.
+
+ To exercise it, navigate to a large directory (say \c /bin), and scroll
+ to the bottom. Log messages appear showing the data being retrieved.
+
Let's take a tour of \c {FileListModel}'s code.
\section1 FileListModel Class Definition
diff --git a/examples/widgets/draganddrop/CMakeLists.txt b/examples/widgets/draganddrop/CMakeLists.txt
index fbad523a73..87ba702aca 100644
--- a/examples/widgets/draganddrop/CMakeLists.txt
+++ b/examples/widgets/draganddrop/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from draganddrop.pro.
-add_subdirectory(draggableicons)
-add_subdirectory(draggabletext)
-add_subdirectory(dropsite)
-add_subdirectory(fridgemagnets)
-add_subdirectory(puzzle)
+qt_internal_add_example(draggableicons)
+qt_internal_add_example(draggabletext)
+qt_internal_add_example(dropsite)
+qt_internal_add_example(fridgemagnets)
+qt_internal_add_example(puzzle)
diff --git a/examples/widgets/effects/CMakeLists.txt b/examples/widgets/effects/CMakeLists.txt
index 6e8a892de1..1f62945f76 100644
--- a/examples/widgets/effects/CMakeLists.txt
+++ b/examples/widgets/effects/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from effects.pro.
-add_subdirectory(blurpicker)
-add_subdirectory(fademessage)
+qt_internal_add_example(blurpicker)
+qt_internal_add_example(fademessage)
diff --git a/examples/widgets/gestures/CMakeLists.txt b/examples/widgets/gestures/CMakeLists.txt
index eb02ee41a9..34fb6d0202 100644
--- a/examples/widgets/gestures/CMakeLists.txt
+++ b/examples/widgets/gestures/CMakeLists.txt
@@ -3,4 +3,4 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(imagegestures)
+qt_internal_add_example(imagegestures)
diff --git a/examples/widgets/graphicsview/CMakeLists.txt b/examples/widgets/graphicsview/CMakeLists.txt
index a60ba190ef..961807eb55 100644
--- a/examples/widgets/graphicsview/CMakeLists.txt
+++ b/examples/widgets/graphicsview/CMakeLists.txt
@@ -1,15 +1,15 @@
# Generated from graphicsview.pro.
-add_subdirectory(chip)
-add_subdirectory(elasticnodes)
-add_subdirectory(embeddeddialogs)
-add_subdirectory(collidingmice)
-add_subdirectory(basicgraphicslayouts)
-add_subdirectory(diagramscene)
-add_subdirectory(flowlayout)
-add_subdirectory(anchorlayout)
-add_subdirectory(simpleanchorlayout)
-add_subdirectory(weatheranchorlayout)
+qt_internal_add_example(chip)
+qt_internal_add_example(elasticnodes)
+qt_internal_add_example(embeddeddialogs)
+qt_internal_add_example(collidingmice)
+qt_internal_add_example(basicgraphicslayouts)
+qt_internal_add_example(diagramscene)
+qt_internal_add_example(flowlayout)
+qt_internal_add_example(anchorlayout)
+qt_internal_add_example(simpleanchorlayout)
+qt_internal_add_example(weatheranchorlayout)
if(QT_FEATURE_cursor AND QT_FEATURE_draganddrop)
- add_subdirectory(dragdroprobot)
+ qt_internal_add_example(dragdroprobot)
endif()
diff --git a/examples/widgets/itemviews/CMakeLists.txt b/examples/widgets/itemviews/CMakeLists.txt
index 96f03a2e61..10d77c43c8 100644
--- a/examples/widgets/itemviews/CMakeLists.txt
+++ b/examples/widgets/itemviews/CMakeLists.txt
@@ -1,27 +1,27 @@
# Generated from itemviews.pro.
-add_subdirectory(addressbook)
-add_subdirectory(basicsortfiltermodel)
-add_subdirectory(chart)
-add_subdirectory(coloreditorfactory)
-add_subdirectory(combowidgetmapper)
-add_subdirectory(customsortfiltermodel)
-add_subdirectory(dirview)
-add_subdirectory(editabletreemodel)
-add_subdirectory(fetchmore)
-add_subdirectory(flattreeview)
-add_subdirectory(frozencolumn)
-add_subdirectory(interview)
-add_subdirectory(pixelator)
-add_subdirectory(simpletreemodel)
-add_subdirectory(simplewidgetmapper)
-add_subdirectory(spinboxdelegate)
-add_subdirectory(spreadsheet)
-add_subdirectory(stardelegate)
-add_subdirectory(storageview)
+qt_internal_add_example(addressbook)
+qt_internal_add_example(basicsortfiltermodel)
+qt_internal_add_example(chart)
+qt_internal_add_example(coloreditorfactory)
+qt_internal_add_example(combowidgetmapper)
+qt_internal_add_example(customsortfiltermodel)
+qt_internal_add_example(dirview)
+qt_internal_add_example(editabletreemodel)
+qt_internal_add_example(fetchmore)
+qt_internal_add_example(flattreeview)
+qt_internal_add_example(frozencolumn)
+qt_internal_add_example(interview)
+qt_internal_add_example(pixelator)
+qt_internal_add_example(simpletreemodel)
+qt_internal_add_example(simplewidgetmapper)
+qt_internal_add_example(spinboxdelegate)
+qt_internal_add_example(spreadsheet)
+qt_internal_add_example(stardelegate)
+qt_internal_add_example(storageview)
if(QT_FEATURE_draganddrop)
- add_subdirectory(puzzle)
+ qt_internal_add_example(puzzle)
endif()
if(TARGET Qt::Xml)
- add_subdirectory(simpledommodel)
+ qt_internal_add_example(simpledommodel)
endif()
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
index 3ee80617c0..5c93aba6f4 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
@@ -54,8 +54,10 @@
#include <QDir>
#include <QPalette>
+static const int batchSize = 100;
+
FileListModel::FileListModel(QObject *parent)
- : QAbstractListModel(parent), fileCount(0)
+ : QAbstractListModel(parent)
{}
//![4]
@@ -67,24 +69,33 @@ int FileListModel::rowCount(const QModelIndex &parent) const
QVariant FileListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
- return QVariant();
-
- if (index.row() >= fileList.size() || index.row() < 0)
- return QVariant();
-
- if (role == Qt::DisplayRole) {
- return fileList.at(index.row());
- } else if (role == Qt::BackgroundRole) {
- int batch = (index.row() / 100) % 2;
- if (batch == 0)
- return qApp->palette().base();
- else
- return qApp->palette().alternateBase();
+ return {};
+
+ const int row = index.row();
+ if (row >= fileList.size() || row < 0)
+ return {};
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return fileList.at(row).fileName();
+ case Qt::BackgroundRole: {
+ const int batch = row / batchSize;
+ const QPalette &palette = QGuiApplication::palette();
+ return (batch % 2) != 0 ? palette.alternateBase() : palette.base();
+ }
+ case Qt::DecorationRole:
+ return iconProvider.icon(fileList.at(row));
}
- return QVariant();
+ return {};
}
+
//![4]
+QFileInfo FileListModel::fileInfoAt(const QModelIndex &index) const
+{
+ return fileList.at(index.row());
+}
+
//![1]
bool FileListModel::canFetchMore(const QModelIndex &parent) const
{
@@ -99,19 +110,20 @@ void FileListModel::fetchMore(const QModelIndex &parent)
{
if (parent.isValid())
return;
- int remainder = fileList.size() - fileCount;
- int itemsToFetch = qMin(100, remainder);
+ const int start = fileCount;
+ const int remainder = int(fileList.size()) - start;
+ const int itemsToFetch = qMin(batchSize, remainder);
if (itemsToFetch <= 0)
return;
- beginInsertRows(QModelIndex(), fileCount, fileCount + itemsToFetch - 1);
+ beginInsertRows(QModelIndex(), start, start + itemsToFetch - 1);
fileCount += itemsToFetch;
endInsertRows();
- emit numberPopulated(itemsToFetch);
+ emit numberPopulated(path, start, itemsToFetch, int(fileList.size()));
}
//![2]
@@ -121,7 +133,8 @@ void FileListModel::setDirPath(const QString &path)
QDir dir(path);
beginResetModel();
- fileList = dir.entryList();
+ this->path = path;
+ fileList = dir.entryInfoList(QDir::NoDot | QDir::AllEntries, QDir::Name);
fileCount = 0;
endResetModel();
}
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.h b/examples/widgets/itemviews/fetchmore/filelistmodel.h
index 35cf6f7b46..1cd61f8c8e 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.h
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.h
@@ -52,7 +52,8 @@
#define FILELISTMODEL_H
#include <QAbstractListModel>
-#include <QStringList>
+#include <QFileInfoList>
+#include <QFileIconProvider>
//![0]
class FileListModel : public QAbstractListModel
@@ -65,8 +66,10 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QFileInfo fileInfoAt(const QModelIndex &) const;
+
signals:
- void numberPopulated(int number);
+ void numberPopulated(const QString &path, int start, int number, int total);
public slots:
void setDirPath(const QString &path);
@@ -76,8 +79,10 @@ protected:
void fetchMore(const QModelIndex &parent) override;
private:
- QStringList fileList;
- int fileCount;
+ QFileInfoList fileList;
+ QString path;
+ QFileIconProvider iconProvider;
+ int fileCount = 0;
};
//![0]
diff --git a/examples/widgets/itemviews/fetchmore/window.cpp b/examples/widgets/itemviews/fetchmore/window.cpp
index fa23bddc73..64746c18f8 100644
--- a/examples/widgets/itemviews/fetchmore/window.cpp
+++ b/examples/widgets/itemviews/fetchmore/window.cpp
@@ -56,37 +56,43 @@
Window::Window(QWidget *parent)
: QWidget(parent)
{
- FileListModel *model = new FileListModel(this);
- model->setDirPath(QLibraryInfo::path(QLibraryInfo::PrefixPath));
+ model = new FileListModel(this);
+ model->setDirPath(QDir::rootPath());
- QLabel *label = new QLabel(tr("&Directory:"));
- QLineEdit *lineEdit = new QLineEdit;
- label->setBuddy(lineEdit);
-
- QListView *view = new QListView;
+ view = new QListView;
view->setModel(model);
- logViewer = new QTextBrowser(this);
- logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
+ logViewer = new QPlainTextEdit(this);
+ logViewer->setReadOnly(true);
+ logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
+ QSizePolicy::Preferred));
- connect(lineEdit, &QLineEdit::textChanged,
- model, &FileListModel::setDirPath);
- connect(lineEdit, &QLineEdit::textChanged,
- logViewer, &QTextEdit::clear);
connect(model, &FileListModel::numberPopulated,
this, &Window::updateLog);
+ connect(view, &QAbstractItemView::activated,
+ this, &Window::activated);
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(label, 0, 0);
- layout->addWidget(lineEdit, 0, 1);
- layout->addWidget(view, 1, 0, 1, 2);
- layout->addWidget(logViewer, 2, 0, 1, 2);
+ auto *layout = new QVBoxLayout(this);
+ layout->addWidget(view);
+ layout->addWidget(logViewer);
- setLayout(layout);
setWindowTitle(tr("Fetch More Example"));
}
-void Window::updateLog(int number)
+void Window::updateLog(const QString &path, int start, int number, int total)
+{
+ const int last = start + number - 1;
+ const QString nativePath = QDir::toNativeSeparators(path);
+ const QString message = tr("%1..%2/%3 items from \"%4\" added.")
+ .arg(start).arg(last).arg(total).arg(nativePath);
+ logViewer->appendPlainText(message);
+}
+
+void Window::activated(const QModelIndex &index)
{
- logViewer->append(tr("%1 items added.").arg(number));
+ const QFileInfo fi = model->fileInfoAt(index);
+ if (fi.isDir()) {
+ logViewer->clear();
+ model->setDirPath(fi.absoluteFilePath());
+ }
}
diff --git a/examples/widgets/itemviews/fetchmore/window.h b/examples/widgets/itemviews/fetchmore/window.h
index 61bcb94bde..1f7c2a8728 100644
--- a/examples/widgets/itemviews/fetchmore/window.h
+++ b/examples/widgets/itemviews/fetchmore/window.h
@@ -54,9 +54,13 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
-class QTextBrowser;
+class QModelIndex;
+class QListView;
+class QPlainTextEdit;
QT_END_NAMESPACE
+class FileListModel;
+
class Window : public QWidget
{
Q_OBJECT
@@ -65,10 +69,13 @@ public:
Window(QWidget *parent = nullptr);
public slots:
- void updateLog(int number);
+ void updateLog(const QString &path, int start, int number, int total);
+ void activated(const QModelIndex &);
private:
- QTextBrowser *logViewer;
+ QPlainTextEdit *logViewer;
+ FileListModel *model;
+ QListView *view;
};
#endif // WINDOW_H
diff --git a/examples/widgets/layouts/CMakeLists.txt b/examples/widgets/layouts/CMakeLists.txt
index eaca669248..656b602650 100644
--- a/examples/widgets/layouts/CMakeLists.txt
+++ b/examples/widgets/layouts/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from layouts.pro.
-add_subdirectory(basiclayouts)
-add_subdirectory(borderlayout)
-add_subdirectory(dynamiclayouts)
-add_subdirectory(flowlayout)
+qt_internal_add_example(basiclayouts)
+qt_internal_add_example(borderlayout)
+qt_internal_add_example(dynamiclayouts)
+qt_internal_add_example(flowlayout)
diff --git a/examples/widgets/mainwindows/CMakeLists.txt b/examples/widgets/mainwindows/CMakeLists.txt
index 8bb5f52f92..ba87029ef8 100644
--- a/examples/widgets/mainwindows/CMakeLists.txt
+++ b/examples/widgets/mainwindows/CMakeLists.txt
@@ -1,8 +1,8 @@
# Generated from mainwindows.pro.
-add_subdirectory(application)
-add_subdirectory(dockwidgets)
-add_subdirectory(mainwindow)
-add_subdirectory(mdi)
-add_subdirectory(menus)
-add_subdirectory(sdi)
+qt_internal_add_example(application)
+qt_internal_add_example(dockwidgets)
+qt_internal_add_example(mainwindow)
+qt_internal_add_example(mdi)
+qt_internal_add_example(menus)
+qt_internal_add_example(sdi)
diff --git a/examples/widgets/painting/CMakeLists.txt b/examples/widgets/painting/CMakeLists.txt
index 8a106982cf..40ebafdc31 100644
--- a/examples/widgets/painting/CMakeLists.txt
+++ b/examples/widgets/painting/CMakeLists.txt
@@ -1,14 +1,14 @@
# Generated from painting.pro.
-add_subdirectory(shared) # special case
-add_subdirectory(basicdrawing)
-add_subdirectory(concentriccircles)
-add_subdirectory(affine)
-# add_subdirectory(composition) # special case FIXME: Seems buggy wrt. usesOpenGL function
-add_subdirectory(deform)
-add_subdirectory(gradients)
-add_subdirectory(pathstroke)
-add_subdirectory(imagecomposition)
-add_subdirectory(painterpaths)
-add_subdirectory(transformations)
-add_subdirectory(fontsampler)
+#add_subdirectory(shared) # special case pulled in by other subdirs as needed
+qt_internal_add_example(basicdrawing)
+qt_internal_add_example(concentriccircles)
+qt_internal_add_example(affine)
+# qt_internal_add_example(composition) # special case FIXME: Seems buggy wrt. usesOpenGL function
+qt_internal_add_example(deform)
+qt_internal_add_example(gradients)
+qt_internal_add_example(pathstroke)
+qt_internal_add_example(imagecomposition)
+qt_internal_add_example(painterpaths)
+qt_internal_add_example(transformations)
+qt_internal_add_example(fontsampler)
diff --git a/examples/widgets/painting/affine/.prev_CMakeLists.txt b/examples/widgets/painting/affine/.prev_CMakeLists.txt
index d367ef75bd..4efe5f28a7 100644
--- a/examples/widgets/painting/affine/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/affine/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(affine PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(affine "shared"
diff --git a/examples/widgets/painting/affine/CMakeLists.txt b/examples/widgets/painting/affine/CMakeLists.txt
index c3323693b8..21f6c41028 100644
--- a/examples/widgets/painting/affine/CMakeLists.txt
+++ b/examples/widgets/painting/affine/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(affine PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(affine PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(affine "shared"
diff --git a/examples/widgets/painting/composition/.prev_CMakeLists.txt b/examples/widgets/painting/composition/.prev_CMakeLists.txt
index 5e3cb8c10c..7cf2aab45f 100644
--- a/examples/widgets/painting/composition/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/composition/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(composition PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(composition "shared"
diff --git a/examples/widgets/painting/composition/CMakeLists.txt b/examples/widgets/painting/composition/CMakeLists.txt
index 8192439737..0394e6a312 100644
--- a/examples/widgets/painting/composition/CMakeLists.txt
+++ b/examples/widgets/painting/composition/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(composition PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(composition PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(composition "shared"
diff --git a/examples/widgets/painting/deform/.prev_CMakeLists.txt b/examples/widgets/painting/deform/.prev_CMakeLists.txt
index 4462680de7..c99df00a5a 100644
--- a/examples/widgets/painting/deform/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/deform/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(deform PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(deform "shared"
diff --git a/examples/widgets/painting/deform/CMakeLists.txt b/examples/widgets/painting/deform/CMakeLists.txt
index c2517ac66f..6ab43cc371 100644
--- a/examples/widgets/painting/deform/CMakeLists.txt
+++ b/examples/widgets/painting/deform/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(deform PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(deform PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(deform "shared"
diff --git a/examples/widgets/painting/fontsampler/CMakeLists.txt b/examples/widgets/painting/fontsampler/CMakeLists.txt
index d3a7680bdc..76bae96edd 100644
--- a/examples/widgets/painting/fontsampler/CMakeLists.txt
+++ b/examples/widgets/painting/fontsampler/CMakeLists.txt
@@ -18,6 +18,7 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/fontsampler")
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
+find_package(Qt6 COMPONENTS PrintSupport)
qt_add_executable(fontsampler
main.cpp
diff --git a/examples/widgets/painting/gradients/.prev_CMakeLists.txt b/examples/widgets/painting/gradients/.prev_CMakeLists.txt
index 7e798d032e..1260b18089 100644
--- a/examples/widgets/painting/gradients/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/gradients/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(gradients PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(gradients "shared"
diff --git a/examples/widgets/painting/gradients/CMakeLists.txt b/examples/widgets/painting/gradients/CMakeLists.txt
index 6ad4dfa771..bfc9ea888b 100644
--- a/examples/widgets/painting/gradients/CMakeLists.txt
+++ b/examples/widgets/painting/gradients/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(gradients PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(gradients PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(gradients "shared"
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp
index 76d5818d32..045da2b0c0 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -105,6 +105,8 @@ uint ShadeWidget::colorAt(int x)
for (int i = 1; i < pts.size(); ++i) {
if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) {
QLineF l(pts.at(i - 1), pts.at(i));
+ if (qIsNull(l.dx()))
+ continue;
l.setLength(l.length() * ((x - l.x1()) / l.dx()));
return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))),
qRound(qMin(l.y2(), qreal(m_shade.height() - 1))));
diff --git a/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt b/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
index 22a6635164..e2c1d5f793 100644
--- a/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
+++ b/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
@@ -42,147 +42,42 @@ target_link_libraries(pathstroke PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(pathstroke "shared"
diff --git a/examples/widgets/painting/pathstroke/CMakeLists.txt b/examples/widgets/painting/pathstroke/CMakeLists.txt
index 17de61fede..54e61e1c32 100644
--- a/examples/widgets/painting/pathstroke/CMakeLists.txt
+++ b/examples/widgets/painting/pathstroke/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(pathstroke PUBLIC
# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
# special case end
@@ -52,147 +52,42 @@ target_link_libraries(pathstroke PUBLIC
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
)
qt6_add_resources(pathstroke "shared"
diff --git a/examples/widgets/painting/shared/CMakeLists.txt b/examples/widgets/painting/shared/CMakeLists.txt
index 9d43e4a980..0fc65d3d99 100644
--- a/examples/widgets/painting/shared/CMakeLists.txt
+++ b/examples/widgets/painting/shared/CMakeLists.txt
@@ -1,14 +1,6 @@
# special case skip regeneration
# Port of shared.pri to be included by painting examples
-if(NOT TARGET Qt::Widgets)
- find_package(Qt6 REQUIRED COMPONENTS Widgets)
-endif()
-
-if(NOT TARGET Qt::OpenGL)
- find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
-endif()
-
add_library(painting_shared OBJECT)
add_library(painting_shared::painting_shared ALIAS painting_shared)
qt6_wrap_cpp(moc_files arthurwidgets.h hoverpoints.h) # no automoc for OBJECT libs:-/
diff --git a/examples/widgets/painting/shared/use_lib.cmake b/examples/widgets/painting/shared/use_lib.cmake
new file mode 100644
index 0000000000..11e9c2cf71
--- /dev/null
+++ b/examples/widgets/painting/shared/use_lib.cmake
@@ -0,0 +1,13 @@
+# Include this file in your example project to use the library defined in this directory.
+# This avoids find_package calls in a directory scope different from the directory scope of the
+# consuming target.
+
+if(NOT TARGET Qt::Widgets)
+ find_package(Qt6 REQUIRED COMPONENTS Widgets)
+endif()
+
+if(NOT TARGET Qt::OpenGL)
+ find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
+endif()
+
+add_subdirectory("${CMAKE_CURRENT_LIST_DIR}" painting_shared)
diff --git a/examples/widgets/richtext/CMakeLists.txt b/examples/widgets/richtext/CMakeLists.txt
index adb98e38f9..86bbcccea5 100644
--- a/examples/widgets/richtext/CMakeLists.txt
+++ b/examples/widgets/richtext/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from richtext.pro.
-add_subdirectory(calendar)
-add_subdirectory(orderform)
-add_subdirectory(syntaxhighlighter)
-add_subdirectory(textedit)
+qt_internal_add_example(calendar)
+qt_internal_add_example(orderform)
+qt_internal_add_example(syntaxhighlighter)
+qt_internal_add_example(textedit)
diff --git a/examples/widgets/richtext/textedit/.prev_CMakeLists.txt b/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
index 97fde062dd..c32496a98b 100644
--- a/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
+++ b/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
@@ -59,6 +59,7 @@ set(textedit_resource_files
"images/mac/textleft.png"
"images/mac/textright.png"
"images/mac/textunder.png"
+ "images/mac/textundercolor.png"
"images/mac/zoomin.png"
"images/mac/zoomout.png"
"images/win/checkbox-checked.png"
@@ -82,6 +83,7 @@ set(textedit_resource_files
"images/win/textleft.png"
"images/win/textright.png"
"images/win/textunder.png"
+ "images/win/textundercolor.png"
"images/win/zoomin.png"
"images/win/zoomout.png"
)
diff --git a/examples/widgets/richtext/textedit/CMakeLists.txt b/examples/widgets/richtext/textedit/CMakeLists.txt
index a376f9f747..8940fd5abf 100644
--- a/examples/widgets/richtext/textedit/CMakeLists.txt
+++ b/examples/widgets/richtext/textedit/CMakeLists.txt
@@ -65,6 +65,7 @@ set(textedit_resource_files
"images/mac/textleft.png"
"images/mac/textright.png"
"images/mac/textunder.png"
+ "images/mac/textundercolor.png"
"images/mac/zoomin.png"
"images/mac/zoomout.png"
"images/win/checkbox-checked.png"
@@ -88,6 +89,7 @@ set(textedit_resource_files
"images/win/textleft.png"
"images/win/textright.png"
"images/win/textunder.png"
+ "images/win/textundercolor.png"
"images/win/zoomin.png"
"images/win/zoomout.png"
)
diff --git a/examples/widgets/richtext/textedit/images/mac/textundercolor.png b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
new file mode 100644
index 0000000000..30e24e61c3
--- /dev/null
+++ b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textundercolor.png b/examples/widgets/richtext/textedit/images/win/textundercolor.png
new file mode 100644
index 0000000000..30e24e61c3
--- /dev/null
+++ b/examples/widgets/richtext/textedit/images/win/textundercolor.png
Binary files differ
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 194e1e3d92..66a3370811 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@@ -48,6 +48,8 @@
**
****************************************************************************/
+#include "textedit.h"
+
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
@@ -84,8 +86,6 @@
#endif
#endif
-#include "textedit.h"
-
#ifdef Q_OS_MAC
const QString rsrcPath = ":/images/mac";
#else
@@ -125,19 +125,20 @@ TextEdit::TextEdit(QWidget *parent)
colorChanged(textEdit->textColor());
alignmentChanged(textEdit->alignment());
- connect(textEdit->document(), &QTextDocument::modificationChanged,
+ auto *document = textEdit->document();
+ connect(document, &QTextDocument::modificationChanged,
actionSave, &QAction::setEnabled);
- connect(textEdit->document(), &QTextDocument::modificationChanged,
+ connect(document, &QTextDocument::modificationChanged,
this, &QWidget::setWindowModified);
- connect(textEdit->document(), &QTextDocument::undoAvailable,
+ connect(document, &QTextDocument::undoAvailable,
actionUndo, &QAction::setEnabled);
- connect(textEdit->document(), &QTextDocument::redoAvailable,
+ connect(document, &QTextDocument::redoAvailable,
actionRedo, &QAction::setEnabled);
- setWindowModified(textEdit->document()->isModified());
- actionSave->setEnabled(textEdit->document()->isModified());
- actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
- actionRedo->setEnabled(textEdit->document()->isRedoAvailable());
+ setWindowModified(document->isModified());
+ actionSave->setEnabled(document->isModified());
+ actionUndo->setEnabled(document->isUndoAvailable());
+ actionRedo->setEnabled(document->isRedoAvailable());
#ifndef QT_NO_CLIPBOARD
actionCut->setEnabled(false);
@@ -145,7 +146,8 @@ TextEdit::TextEdit(QWidget *parent)
actionCopy->setEnabled(false);
connect(textEdit, &QTextEdit::copyAvailable, actionCopy, &QAction::setEnabled);
- connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &TextEdit::clipboardDataChanged);
+ connect(QGuiApplication::clipboard(), &QClipboard::dataChanged,
+ this, &TextEdit::clipboardDataChanged);
#endif
textEdit->setFocus();
@@ -254,7 +256,7 @@ void TextEdit::setupEditActions()
actionPaste->setPriority(QAction::LowPriority);
actionPaste->setShortcut(QKeySequence::Paste);
tb->addAction(actionPaste);
- if (const QMimeData *md = QApplication::clipboard()->mimeData())
+ if (const QMimeData *md = QGuiApplication::clipboard()->mimeData())
actionPaste->setEnabled(md->hasText());
#endif
}
@@ -325,11 +327,11 @@ void TextEdit::setupTextActions()
actionIndentLess->setShortcut(Qt::CTRL | Qt::Key_BracketLeft);
actionIndentLess->setPriority(QAction::LowPriority);
- // Make sure the alignLeft is always left of the alignRight
+ // Make sure the alignLeft is always left of the alignRight
QActionGroup *alignGroup = new QActionGroup(this);
connect(alignGroup, &QActionGroup::triggered, this, &TextEdit::textAlign);
- if (QApplication::isLeftToRight()) {
+ if (QGuiApplication::isLeftToRight()) {
alignGroup->addAction(actionAlignLeft);
alignGroup->addAction(actionAlignCenter);
alignGroup->addAction(actionAlignRight);
@@ -354,6 +356,10 @@ void TextEdit::setupTextActions()
actionTextColor = menu->addAction(pix, tr("&Color..."), this, &TextEdit::textColor);
tb->addAction(actionTextColor);
+ const QIcon underlineColorIcon(rsrcPath + "/textundercolor.png");
+ actionUnderlineColor = menu->addAction(underlineColorIcon, tr("Underline color..."), this, &TextEdit::underlineColor);
+ tb->addAction(actionUnderlineColor);
+
menu->addSeparator();
const QIcon checkboxIcon = QIcon::fromTheme("status-checkbox-checked", QIcon(rsrcPath + "/checkbox-checked.png"));
@@ -370,23 +376,23 @@ void TextEdit::setupTextActions()
comboStyle = new QComboBox(tb);
tb->addWidget(comboStyle);
- comboStyle->addItem("Standard");
- comboStyle->addItem("Bullet List (Disc)");
- comboStyle->addItem("Bullet List (Circle)");
- comboStyle->addItem("Bullet List (Square)");
- comboStyle->addItem("Task List (Unchecked)");
- comboStyle->addItem("Task List (Checked)");
- comboStyle->addItem("Ordered List (Decimal)");
- comboStyle->addItem("Ordered List (Alpha lower)");
- comboStyle->addItem("Ordered List (Alpha upper)");
- comboStyle->addItem("Ordered List (Roman lower)");
- comboStyle->addItem("Ordered List (Roman upper)");
- comboStyle->addItem("Heading 1");
- comboStyle->addItem("Heading 2");
- comboStyle->addItem("Heading 3");
- comboStyle->addItem("Heading 4");
- comboStyle->addItem("Heading 5");
- comboStyle->addItem("Heading 6");
+ comboStyle->addItems({"Standard",
+ "Bullet List (Disc)",
+ "Bullet List (Circle)",
+ "Bullet List (Square)",
+ "Task List (Unchecked)",
+ "Task List (Checked)",
+ "Ordered List (Decimal)",
+ "Ordered List (Alpha lower)",
+ "Ordered List (Alpha upper)",
+ "Ordered List (Roman lower)",
+ "Ordered List (Roman upper)",
+ "Heading 1",
+ "Heading 2",
+ "Heading 3",
+ "Heading 4",
+ "Heading 5",
+ "Heading 6"}),
connect(comboStyle, &QComboBox::activated, this, &TextEdit::textStyle);
@@ -417,14 +423,15 @@ bool TextEdit::load(const QString &f)
QByteArray data = file.readAll();
QMimeDatabase db;
- if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/html")) {
+ const QString &mimeTypeName = db.mimeTypeForFileNameAndData(f, data).name();
+ if (mimeTypeName == u"text/html") {
auto encoding = QStringDecoder::encodingForHtml(data);
QString str = QStringDecoder(encoding ? *encoding : QStringDecoder::Utf8)(data);
- QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename);
- textEdit->document()->setBaseUrl(baseUrl);
+ QUrl fileUrl = f.startsWith(u':') ? QUrl(f) : QUrl::fromLocalFile(f);
+ textEdit->document()->setBaseUrl(fileUrl.adjusted(QUrl::RemoveFilename));
textEdit->setHtml(str);
#if QT_CONFIG(textmarkdownreader)
- } else if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/markdown")) {
+ } else if (mimeTypeName == u"text/markdown") {
textEdit->setMarkdown(QString::fromUtf8(data));
#endif
} else {
@@ -447,7 +454,7 @@ bool TextEdit::maybeSave()
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
return fileSave();
- else if (ret == QMessageBox::Cancel)
+ if (ret == QMessageBox::Cancel)
return false;
return true;
}
@@ -471,7 +478,7 @@ void TextEdit::fileNew()
{
if (maybeSave()) {
textEdit->clear();
- setCurrentFileName(QString());
+ setCurrentFileName({});
}
}
@@ -480,18 +487,18 @@ void TextEdit::fileOpen()
QFileDialog fileDialog(this, tr("Open File..."));
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setFileMode(QFileDialog::ExistingFile);
- fileDialog.setMimeTypeFilters(QStringList()
+ fileDialog.setMimeTypeFilters({
#if QT_CONFIG(texthtmlparser)
- << "text/html"
+ "text/html",
#endif
#if QT_CONFIG(textmarkdownreader)
- << "text/markdown"
+ "text/markdown",
#endif
- << "text/plain");
+ "text/plain"});
if (fileDialog.exec() != QDialog::Accepted)
return;
- const QString fn = fileDialog.selectedFiles().first();
+ const QString fn = fileDialog.selectedFiles().constFirst();
if (load(fn))
statusBar()->showMessage(tr("Opened \"%1\"").arg(QDir::toNativeSeparators(fn)));
else
@@ -500,9 +507,7 @@ void TextEdit::fileOpen()
bool TextEdit::fileSave()
{
- if (fileName.isEmpty())
- return fileSaveAs();
- if (fileName.startsWith(QStringLiteral(":/")))
+ if (fileName.isEmpty() || fileName.startsWith(u":/"))
return fileSaveAs();
QTextDocumentWriter writer(fileName);
@@ -521,22 +526,21 @@ bool TextEdit::fileSaveAs()
{
QFileDialog fileDialog(this, tr("Save as..."));
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
- QStringList mimeTypes;
- mimeTypes << "text/plain"
+ QStringList mimeTypes{"text/plain",
#if QT_CONFIG(textodfwriter)
- << "application/vnd.oasis.opendocument.text"
+ "application/vnd.oasis.opendocument.text",
#endif
#if QT_CONFIG(textmarkdownwriter)
- << "text/markdown"
+ "text/markdown",
#endif
- << "text/html";
+ "text/html"};
fileDialog.setMimeTypeFilters(mimeTypes);
#if QT_CONFIG(textodfwriter)
fileDialog.setDefaultSuffix("odt");
#endif
if (fileDialog.exec() != QDialog::Accepted)
return false;
- const QString fn = fileDialog.selectedFiles().first();
+ const QString fn = fileDialog.selectedFiles().constFirst();
setCurrentFileName(fn);
return fileSave();
}
@@ -545,13 +549,12 @@ void TextEdit::filePrint()
{
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer(QPrinter::HighResolution);
- QPrintDialog *dlg = new QPrintDialog(&printer, this);
+ QPrintDialog dlg(&printer, this);
if (textEdit->textCursor().hasSelection())
- dlg->setOption(QAbstractPrintDialog::PrintSelection);
- dlg->setWindowTitle(tr("Print Document"));
- if (dlg->exec() == QDialog::Accepted)
+ dlg.setOption(QAbstractPrintDialog::PrintSelection);
+ dlg.setWindowTitle(tr("Print Document"));
+ if (dlg.exec() == QDialog::Accepted)
textEdit->print(&printer);
- delete dlg;
#endif
}
@@ -560,21 +563,11 @@ void TextEdit::filePrintPreview()
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
QPrinter printer(QPrinter::HighResolution);
QPrintPreviewDialog preview(&printer, this);
- connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview);
+ connect(&preview, &QPrintPreviewDialog::paintRequested, textEdit, &QTextEdit::print);
preview.exec();
#endif
}
-void TextEdit::printPreview(QPrinter *printer)
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
- textEdit->print(printer);
-#else
- Q_UNUSED(printer);
-#endif
-}
-
-
void TextEdit::filePrintPdf()
{
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
@@ -585,13 +578,13 @@ void TextEdit::filePrintPdf()
fileDialog.setDefaultSuffix("pdf");
if (fileDialog.exec() != QDialog::Accepted)
return;
- QString fileName = fileDialog.selectedFiles().first();
+ QString pdfFileName = fileDialog.selectedFiles().constFirst();
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
- printer.setOutputFileName(fileName);
+ printer.setOutputFileName(pdfFileName);
textEdit->document()->print(&printer);
statusBar()->showMessage(tr("Exported \"%1\"")
- .arg(QDir::toNativeSeparators(fileName)));
+ .arg(QDir::toNativeSeparators(pdfFileName)));
//! [0]
#endif
}
@@ -620,14 +613,14 @@ void TextEdit::textItalic()
void TextEdit::textFamily(const QString &f)
{
QTextCharFormat fmt;
- fmt.setFontFamily(f);
+ fmt.setFontFamilies({f});
mergeFormatOnWordOrSelection(fmt);
}
void TextEdit::textSize(const QString &p)
{
qreal pointSize = p.toFloat();
- if (p.toFloat() > 0) {
+ if (pointSize > 0) {
QTextCharFormat fmt;
fmt.setFontPointSize(pointSize);
mergeFormatOnWordOrSelection(fmt);
@@ -729,6 +722,17 @@ void TextEdit::textColor()
colorChanged(col);
}
+void TextEdit::underlineColor()
+{
+ QColor col = QColorDialog::getColor(Qt::black, this);
+ if (!col.isValid())
+ return;
+ QTextCharFormat fmt;
+ fmt.setUnderlineColor(col);
+ mergeFormatOnWordOrSelection(fmt);
+ colorChanged(col);
+}
+
void TextEdit::textAlign(QAction *a)
{
if (a == actionAlignLeft)
@@ -842,7 +846,7 @@ void TextEdit::cursorPositionChanged()
void TextEdit::clipboardDataChanged()
{
#ifndef QT_NO_CLIPBOARD
- if (const QMimeData *md = QApplication::clipboard()->mimeData())
+ if (const QMimeData *md = QGuiApplication::clipboard()->mimeData())
actionPaste->setEnabled(md->hasText());
#endif
}
@@ -881,13 +885,13 @@ void TextEdit::colorChanged(const QColor &c)
void TextEdit::alignmentChanged(Qt::Alignment a)
{
- if (a & Qt::AlignLeft)
+ if (a.testFlag(Qt::AlignLeft))
actionAlignLeft->setChecked(true);
- else if (a & Qt::AlignHCenter)
+ else if (a.testFlag(Qt::AlignHCenter))
actionAlignCenter->setChecked(true);
- else if (a & Qt::AlignRight)
+ else if (a.testFlag(Qt::AlignRight))
actionAlignRight->setChecked(true);
- else if (a & Qt::AlignJustify)
+ else if (a.testFlag(Qt::AlignJustify))
actionAlignJustify->setChecked(true);
}
diff --git a/examples/widgets/richtext/textedit/textedit.h b/examples/widgets/richtext/textedit/textedit.h
index 07a307f83d..6b95891d31 100644
--- a/examples/widgets/richtext/textedit/textedit.h
+++ b/examples/widgets/richtext/textedit/textedit.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@@ -52,8 +52,6 @@
#define TEXTEDIT_H
#include <QMainWindow>
-#include <QMap>
-#include <QPointer>
QT_BEGIN_NAMESPACE
class QAction;
@@ -95,6 +93,7 @@ private slots:
void textSize(const QString &p);
void textStyle(int styleIndex);
void textColor();
+ void underlineColor();
void textAlign(QAction *a);
void setChecked(bool checked);
void indent();
@@ -105,7 +104,6 @@ private slots:
void clipboardDataChanged();
void about();
- void printPreview(QPrinter *);
private:
void setupFileActions();
@@ -125,6 +123,7 @@ private:
QAction *actionTextUnderline;
QAction *actionTextItalic;
QAction *actionTextColor;
+ QAction *actionUnderlineColor;
QAction *actionAlignLeft;
QAction *actionAlignCenter;
QAction *actionAlignRight;
@@ -144,7 +143,6 @@ private:
QFontComboBox *comboFont;
QComboBox *comboSize;
- QToolBar *tb;
QString fileName;
QTextEdit *textEdit;
};
diff --git a/examples/widgets/richtext/textedit/textedit.qrc b/examples/widgets/richtext/textedit/textedit.qrc
index 1641acc207..a30d50fdbf 100644
--- a/examples/widgets/richtext/textedit/textedit.qrc
+++ b/examples/widgets/richtext/textedit/textedit.qrc
@@ -22,6 +22,7 @@
<file>images/mac/textleft.png</file>
<file>images/mac/textright.png</file>
<file>images/mac/textunder.png</file>
+ <file>images/mac/textundercolor.png</file>
<file>images/mac/zoomin.png</file>
<file>images/mac/zoomout.png</file>
<file>images/win/checkbox.png</file>
@@ -45,6 +46,7 @@
<file>images/win/textleft.png</file>
<file>images/win/textright.png</file>
<file>images/win/textunder.png</file>
+ <file>images/win/textundercolor.png</file>
<file>images/win/zoomin.png</file>
<file>images/win/zoomout.png</file>
<file>example.html</file>
diff --git a/examples/widgets/scroller/CMakeLists.txt b/examples/widgets/scroller/CMakeLists.txt
index f663cd9890..37ee7ea08f 100644
--- a/examples/widgets/scroller/CMakeLists.txt
+++ b/examples/widgets/scroller/CMakeLists.txt
@@ -1,3 +1,3 @@
# Generated from scroller.pro.
-add_subdirectory(graphicsview)
+qt_internal_add_example(graphicsview)
diff --git a/examples/widgets/tools/CMakeLists.txt b/examples/widgets/tools/CMakeLists.txt
index 022f4a2b8f..0056518f1e 100644
--- a/examples/widgets/tools/CMakeLists.txt
+++ b/examples/widgets/tools/CMakeLists.txt
@@ -1,18 +1,22 @@
# Generated from tools.pro.
-add_subdirectory(completer)
-add_subdirectory(customcompleter)
+qt_internal_add_example(completer)
+qt_internal_add_example(customcompleter)
if(QT_FEATURE_translation) # special case
- add_subdirectory(i18n)
+ qt_internal_add_example(i18n)
endif()
-add_subdirectory(regularexpression)
-add_subdirectory(settingseditor)
-add_subdirectory(styleplugin)
-add_subdirectory(treemodelcompleter)
-add_subdirectory(undo)
-add_subdirectory(undoframework)
+qt_internal_add_example(regularexpression)
+qt_internal_add_example(settingseditor)
+qt_internal_add_example(styleplugin)
+qt_internal_add_example(treemodelcompleter)
+qt_internal_add_example(undo)
+qt_internal_add_example(undoframework)
if(QT_FEATURE_library) # special case
add_subdirectory(echoplugin)
- add_subdirectory(plugandpaint) # special case
+ # special case begin
+ if(QT_FEATURE_inputdialog)
+ qt_internal_add_example(plugandpaint)
+ endif()
+ # special case end
endif()
diff --git a/examples/widgets/tools/echoplugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/CMakeLists.txt
index b848e08e72..380cfcae8e 100644
--- a/examples/widgets/tools/echoplugin/CMakeLists.txt
+++ b/examples/widgets/tools/echoplugin/CMakeLists.txt
@@ -1,4 +1,4 @@
# Generated from echoplugin.pro.
-add_subdirectory(echowindow)
-add_subdirectory(plugin)
+qt_internal_add_example(echowindow)
+qt_internal_add_example(plugin)
diff --git a/examples/widgets/tools/plugandpaint/CMakeLists.txt b/examples/widgets/tools/plugandpaint/CMakeLists.txt
index 4e35d0d0c3..3c997faf21 100644
--- a/examples/widgets/tools/plugandpaint/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/CMakeLists.txt
@@ -1,7 +1,19 @@
# Generated from plugandpaint.pro.
+# special case skip regeneration
+cmake_minimum_required(VERSION 3.14)
+project(plugandpaint LANGUAGES CXX)
-if(NOT QT_FEATURE_inputdialog)
- return()
+find_package(Qt6 COMPONENTS Core Gui Widgets)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
+
add_subdirectory(plugins)
add_subdirectory(app)
diff --git a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
index bdf934fa2c..14cdaeb822 100644
--- a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
@@ -1,23 +1,5 @@
# Generated from app.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(plugandpaint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+# special case skip regeneration
qt_add_executable(plugandpaint
interfaces.h
@@ -31,43 +13,9 @@ set_target_properties(plugandpaint PROPERTIES
MACOSX_BUNDLE TRUE
)
target_link_libraries(plugandpaint PUBLIC
- # Remove: L../plugins
- Qt::Core
- Qt::Gui
Qt::Widgets
- pnp_basictools # special case
+ pnp_basictools
)
-target_link_libraries(plugandpaint PUBLIC pnp_basictools) # special case
-
-if(macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- (
- )
- pnp_basictools$
- )
-endif()
-
-if(NOT macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- pnp_basictools
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (APPLE))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- _debug
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (WIN32))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- d
- )
-endif()
install(TARGETS plugandpaint
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tools/plugandpaint/app/app.pro b/examples/widgets/tools/plugandpaint/app/app.pro
index 558d359e7d..e5ff02ecf2 100644
--- a/examples/widgets/tools/plugandpaint/app/app.pro
+++ b/examples/widgets/tools/plugandpaint/app/app.pro
@@ -18,7 +18,11 @@ LIBS = -L../plugins
macx-xcode {
LIBS += -lpnp_basictools$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})
} else {
- LIBS += -lpnp_basictools
+ android {
+ LIBS += -lpnp_basictools_$${QT_ARCH}
+ } else {
+ LIBS += -lpnp_basictools
+ }
if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug
win32:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)d
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
index 97e4021d61..c66f83ce62 100644
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
@@ -1,23 +1,5 @@
# Generated from basictools.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_basictools LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+# special case skip regeneration
qt_add_plugin(pnp_basictools STATIC)
target_sources(pnp_basictools PRIVATE
@@ -36,9 +18,3 @@ target_link_libraries(pnp_basictools PUBLIC
Qt::Gui
Qt::Widgets
)
-
-install(TARGETS pnp_basictools
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
index bb6948e610..9227dd0537 100644
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
+++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
@@ -1,31 +1,13 @@
# Generated from extrafilters.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_extrafilters LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+# special case skip regeneration
qt_add_plugin(pnp_extrafilters)
target_sources(pnp_extrafilters PRIVATE
extrafiltersplugin.cpp extrafiltersplugin.h
)
set_target_properties(pnp_extrafilters PROPERTIES
- WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
+ LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/app"
)
target_include_directories(pnp_extrafilters PUBLIC
../../app
@@ -38,7 +20,6 @@ target_link_libraries(pnp_extrafilters PUBLIC
)
install(TARGETS pnp_extrafilters
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}/plugins"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}/plugins"
)
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
index 51025b7100..36c8695ae9 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
@@ -66,12 +66,13 @@
#include <QAction>
#include <QClipboard>
#include <QContextMenuEvent>
+#include <QFont>
+#include <QFontDatabase>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFormLayout>
-#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QRegularExpressionMatchIterator>
@@ -106,6 +107,20 @@ static QString codeToPattern(QString code)
return code;
}
+static QFrame *createHorizontalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ return result;
+}
+
+static QFrame *createVerticalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::VLine | QFrame::Sunken);
+ return result;
+}
+
class PatternLineEdit : public QLineEdit
{
Q_OBJECT
@@ -239,6 +254,7 @@ void RegularExpressionDialog::setResultUiEnabled(bool enabled)
{
matchDetailsTreeWidget->setEnabled(enabled);
namedGroupsTreeWidget->setEnabled(enabled);
+ replacementTextEdit->setEnabled(enabled);
}
static void setTextColor(QWidget *widget, const QColor &color)
@@ -264,6 +280,7 @@ void RegularExpressionDialog::refresh()
matchDetailsTreeWidget->clear();
namedGroupsTreeWidget->clear();
regexpStatusLabel->setText(QString());
+ replacementTextEdit->clear();
if (pattern.isEmpty()) {
setResultUiEnabled(false);
@@ -271,12 +288,12 @@ void RegularExpressionDialog::refresh()
return;
}
- QRegularExpression rx(pattern);
- if (!rx.isValid()) {
+ regularExpression.setPattern(pattern);
+ if (!regularExpression.isValid()) {
setTextColor(patternLineEdit, Qt::red);
regexpStatusLabel->setText(tr("Invalid: syntax error at position %1 (%2)")
- .arg(rx.patternErrorOffset())
- .arg(rx.errorString()));
+ .arg(regularExpression.patternErrorOffset())
+ .arg(regularExpression.errorString()));
setResultUiEnabled(false);
setUpdatesEnabled(true);
return;
@@ -308,11 +325,13 @@ void RegularExpressionDialog::refresh()
if (useUnicodePropertiesOptionCheckBox->isChecked())
patternOptions |= QRegularExpression::UseUnicodePropertiesOption;
- rx.setPatternOptions(patternOptions);
+ regularExpression.setPatternOptions(patternOptions);
- const int capturingGroupsCount = rx.captureCount() + 1;
+ const int capturingGroupsCount = regularExpression.captureCount() + 1;
- QRegularExpressionMatchIterator iterator = rx.globalMatch(text, offsetSpinBox->value(), matchType, matchOptions);
+ const int offset = offsetSpinBox->value();
+ QRegularExpressionMatchIterator iterator =
+ regularExpression.globalMatch(text, offset, matchType, matchOptions);
int i = 0;
while (iterator.hasNext()) {
@@ -334,7 +353,7 @@ void RegularExpressionDialog::refresh()
regexpStatusLabel->setText(tr("Valid"));
- const QStringList namedCaptureGroups = rx.namedCaptureGroups();
+ const QStringList namedCaptureGroups = regularExpression.namedCaptureGroups();
for (int i = 0; i < namedCaptureGroups.size(); ++i) {
const QString currentNamedCaptureGroup = namedCaptureGroups.at(i);
@@ -343,28 +362,44 @@ void RegularExpressionDialog::refresh()
namedGroupItem->setText(1, currentNamedCaptureGroup.isNull() ? tr("<no name>") : currentNamedCaptureGroup);
}
+ updateReplacement();
setUpdatesEnabled(true);
}
-void RegularExpressionDialog::setupUi()
+void RegularExpressionDialog::updateReplacement()
{
- QWidget *leftHalfContainer = setupLeftUi();
-
- QFrame *verticalSeparator = new QFrame;
- verticalSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken);
-
- QWidget *rightHalfContainer = setupRightUi();
+ replacementTextEdit->clear();
+ const QString &replacement = replacementLineEdit->text();
+ if (!regularExpression.isValid() || replacement.isEmpty())
+ return;
- QHBoxLayout *mainLayout = new QHBoxLayout;
- mainLayout->addWidget(leftHalfContainer);
- mainLayout->addWidget(verticalSeparator);
- mainLayout->addWidget(rightHalfContainer);
+ QString replaced = subjectTextEdit->toPlainText();
+ replaced.replace(regularExpression, replacement);
+ replacementTextEdit->setPlainText(replaced);
+}
- setLayout(mainLayout);
+void RegularExpressionDialog::setupUi()
+{
+ auto *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(setupTextUi());
+ mainLayout->addWidget(createHorizontalSeparator());
+ auto *horizontalLayout = new QHBoxLayout();
+ mainLayout->addLayout(horizontalLayout);
+ horizontalLayout->addWidget(setupOptionsUi());
+ horizontalLayout->addWidget(createVerticalSeparator());
+ horizontalLayout->addWidget(setupInfoUi());
+
+ auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ patternLineEdit->setFont(font);
+ rawStringLiteralLineEdit->setFont(font);
+ escapedPatternLineEdit->setFont(font);
+ replacementLineEdit->setFont(font);
+ subjectTextEdit->setFont(font);
+ replacementTextEdit->setFont(font);
}
-QWidget *RegularExpressionDialog::setupLeftUi()
+QWidget *RegularExpressionDialog::setupTextUi()
{
QWidget *container = new QWidget;
@@ -387,6 +422,35 @@ QWidget *RegularExpressionDialog::setupLeftUi()
subjectTextEdit = new QPlainTextEdit;
layout->addRow(tr("&Subject text:"), subjectTextEdit);
+ layout->addRow(createHorizontalSeparator());
+
+ QLabel *replaceLabel = new QLabel(tr("<h3>Replacement"));
+ layout->addRow(replaceLabel);
+
+ replacementLineEdit = new QLineEdit;
+ replacementLineEdit->setClearButtonEnabled(true);
+ connect(replacementLineEdit, &QLineEdit::textChanged, this,
+ &RegularExpressionDialog::updateReplacement);
+ layout->addRow(tr("&Replace by:"), replacementLineEdit);
+ replacementLineEdit->setToolTip(tr("Use \\1, \\2... as placeholders for the captured groups."));
+
+ replacementTextEdit = new QPlainTextEdit;
+ replacementTextEdit->setReadOnly(true);
+ layout->addRow(tr("Result:"), replacementTextEdit);
+
+ return container;
+}
+
+QWidget *RegularExpressionDialog::setupOptionsUi()
+{
+ QWidget *container = new QWidget;
+
+ QFormLayout *layout = new QFormLayout(container);
+ layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ layout->setContentsMargins(QMargins());
+
+ layout->addRow(new QLabel(tr("<h3>Options</h3>")));
+
caseInsensitiveOptionCheckBox = new QCheckBox(tr("Case insensitive (/i)"));
dotMatchesEverythingOptionCheckBox = new QCheckBox(tr("Dot matches everything (/s)"));
multilineOptionCheckBox = new QCheckBox(tr("Multiline (/m)"));
@@ -431,7 +495,7 @@ QWidget *RegularExpressionDialog::setupLeftUi()
return container;
}
-QWidget *RegularExpressionDialog::setupRightUi()
+QWidget *RegularExpressionDialog::setupInfoUi()
{
QWidget *container = new QWidget;
@@ -447,9 +511,7 @@ QWidget *RegularExpressionDialog::setupRightUi()
matchDetailsTreeWidget->setSizeAdjustPolicy(QTreeWidget::AdjustToContents);
layout->addRow(tr("Match details:"), matchDetailsTreeWidget);
- QFrame *horizontalSeparator = new QFrame;
- horizontalSeparator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
- layout->addRow(horizontalSeparator);
+ layout->addRow(createHorizontalSeparator());
QLabel *regexpInfoLabel = new QLabel(tr("<h3>Regular expression information</h3>"));
layout->addRow(regexpInfoLabel);
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.h b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
index b0db4d884c..b5d592c3c2 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.h
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
@@ -54,6 +54,7 @@
#define REGULAREXPRESSIONDIALOG_H
#include <QDialog>
+#include <QRegularExpression>
QT_BEGIN_NAMESPACE
class QCheckBox;
@@ -72,18 +73,25 @@ class RegularExpressionDialog : public QDialog
public:
RegularExpressionDialog(QWidget *parent = nullptr);
+private slots:
+ void updateReplacement();
+
private:
void refresh();
void setupUi();
QWidget *setupLeftUi();
- QWidget *setupRightUi();
+ QWidget *setupTextUi();
+ QWidget *setupOptionsUi();
+ QWidget *setupInfoUi();
void setResultUiEnabled(bool enabled);
QLineEdit *patternLineEdit;
QLineEdit *rawStringLiteralLineEdit;
QLineEdit *escapedPatternLineEdit;
+ QLineEdit *replacementLineEdit;
QPlainTextEdit *subjectTextEdit;
+ QPlainTextEdit *replacementTextEdit;
QCheckBox *caseInsensitiveOptionCheckBox;
QCheckBox *dotMatchesEverythingOptionCheckBox;
@@ -104,6 +112,8 @@ private:
QLabel *regexpStatusLabel;
QTreeWidget *namedGroupsTreeWidget;
+
+ QRegularExpression regularExpression;
};
#endif
diff --git a/examples/widgets/touch/CMakeLists.txt b/examples/widgets/touch/CMakeLists.txt
index d2c3152ad8..ca6ef7fcb8 100644
--- a/examples/widgets/touch/CMakeLists.txt
+++ b/examples/widgets/touch/CMakeLists.txt
@@ -3,7 +3,7 @@
if(NOT TARGET Qt::Widgets)
return()
endif()
-add_subdirectory(pinchzoom)
-add_subdirectory(fingerpaint)
-add_subdirectory(knobs)
-add_subdirectory(dials)
+qt_internal_add_example(pinchzoom)
+qt_internal_add_example(fingerpaint)
+qt_internal_add_example(knobs)
+qt_internal_add_example(dials)
diff --git a/examples/widgets/tutorials/CMakeLists.txt b/examples/widgets/tutorials/CMakeLists.txt
index c2fa4a81d7..733eb42151 100644
--- a/examples/widgets/tutorials/CMakeLists.txt
+++ b/examples/widgets/tutorials/CMakeLists.txt
@@ -4,4 +4,4 @@ add_subdirectory(addressbook)
add_subdirectory(widgets)
add_subdirectory(modelview)
add_subdirectory(gettingStarted)
-add_subdirectory(notepad)
+qt_internal_add_example(notepad)
diff --git a/examples/widgets/tutorials/addressbook/CMakeLists.txt b/examples/widgets/tutorials/addressbook/CMakeLists.txt
index a8823d059a..cb00cbc084 100644
--- a/examples/widgets/tutorials/addressbook/CMakeLists.txt
+++ b/examples/widgets/tutorials/addressbook/CMakeLists.txt
@@ -1,9 +1,9 @@
# Generated from addressbook.pro.
-add_subdirectory(part1)
-add_subdirectory(part2)
-add_subdirectory(part3)
-add_subdirectory(part4)
-add_subdirectory(part5)
-add_subdirectory(part6)
-add_subdirectory(part7)
+qt_internal_add_example(part1)
+qt_internal_add_example(part2)
+qt_internal_add_example(part3)
+qt_internal_add_example(part4)
+qt_internal_add_example(part5)
+qt_internal_add_example(part6)
+qt_internal_add_example(part7)
diff --git a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
index 2aa8163029..42cac47b96 100644
--- a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
@@ -1,2 +1 @@
-# Generated from gettingStarted.pro.
-
+add_subdirectory(gsQt)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
index 7a9ade8511..8302fd7598 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from gsqt.pro.
-add_subdirectory(part1)
-add_subdirectory(part2)
-add_subdirectory(part3)
-add_subdirectory(part4)
-add_subdirectory(part5)
+qt_internal_add_example(part1)
+qt_internal_add_example(part2)
+qt_internal_add_example(part3)
+qt_internal_add_example(part4)
+qt_internal_add_example(part5)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
index e2877a26ba..13ed19067b 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part1.pro.
cmake_minimum_required(VERSION 3.14)
-project(part1 LANGUAGES CXX)
+project(getting_started_part1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part1
+qt_add_executable(getting_started_part1
main.cpp
)
-set_target_properties(part1 PROPERTIES
+set_target_properties(getting_started_part1 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part1 PUBLIC
+target_link_libraries(getting_started_part1 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part1
+install(TARGETS getting_started_part1
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
index 65a3ff3539..4f72a9ede8 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part2.pro.
cmake_minimum_required(VERSION 3.14)
-project(part2 LANGUAGES CXX)
+project(getting_started_part2 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part2
+qt_add_executable(getting_started_part2
main.cpp
)
-set_target_properties(part2 PROPERTIES
+set_target_properties(getting_started_part2 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part2 PUBLIC
+target_link_libraries(getting_started_part2 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part2
+install(TARGETS getting_started_part2
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
index 4a9b79b00b..d8a72abd59 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part3.pro.
cmake_minimum_required(VERSION 3.14)
-project(part3 LANGUAGES CXX)
+project(getting_started_part3 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part3
+qt_add_executable(getting_started_part3
main.cpp
)
-set_target_properties(part3 PROPERTIES
+set_target_properties(getting_started_part3 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part3 PUBLIC
+target_link_libraries(getting_started_part3 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part3
+install(TARGETS getting_started_part3
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
index b1b224c70d..3e42635ae4 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part4.pro.
cmake_minimum_required(VERSION 3.14)
-project(part4 LANGUAGES CXX)
+project(getting_started_part4 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part4
+qt_add_executable(getting_started_part4
main.cpp
)
-set_target_properties(part4 PROPERTIES
+set_target_properties(getting_started_part4 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part4 PUBLIC
+target_link_libraries(getting_started_part4 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part4
+install(TARGETS getting_started_part4
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
index 182c2e9a48..c92f60d535 100644
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
+++ b/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from part5.pro.
cmake_minimum_required(VERSION 3.14)
-project(part5 LANGUAGES CXX)
+project(getting_started_part5 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -19,20 +19,20 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
-qt_add_executable(part5
+qt_add_executable(getting_started_part5
main.cpp
)
-set_target_properties(part5 PROPERTIES
+set_target_properties(getting_started_part5 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(part5 PUBLIC
+target_link_libraries(getting_started_part5 PUBLIC
Qt::Core
Qt::Gui
Qt::Widgets
)
-install(TARGETS part5
+install(TARGETS getting_started_part5
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/widgets/tutorials/gettingstartedqt.qdoc b/examples/widgets/tutorials/gettingstartedqt.qdoc
index 32e8845c05..2edc1f07f1 100644
--- a/examples/widgets/tutorials/gettingstartedqt.qdoc
+++ b/examples/widgets/tutorials/gettingstartedqt.qdoc
@@ -320,13 +320,6 @@
\skipto Notepad::~Notepad
\printuntil }
- In order to have the text edit field occupy the whole screen, we add
- \c setCentralWidget to the main window.
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto Notepad::Notepad(QWidget *parent)
- \printuntil }
-
\section2 Project File
The wizard generates the following project file, \c {notepad.pro}, for
diff --git a/examples/widgets/tutorials/modelview/CMakeLists.txt b/examples/widgets/tutorials/modelview/CMakeLists.txt
index 10f2cf6ecf..49ca672e48 100644
--- a/examples/widgets/tutorials/modelview/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/CMakeLists.txt
@@ -1,9 +1,9 @@
# Generated from modelview.pro.
-add_subdirectory(1_readonly)
-add_subdirectory(2_formatting)
-add_subdirectory(3_changingmodel)
-add_subdirectory(4_headers)
-add_subdirectory(5_edit)
-add_subdirectory(6_treeview)
-add_subdirectory(7_selections)
+qt_internal_add_example(1_readonly)
+qt_internal_add_example(2_formatting)
+qt_internal_add_example(3_changingmodel)
+qt_internal_add_example(4_headers)
+qt_internal_add_example(5_edit)
+qt_internal_add_example(6_treeview)
+qt_internal_add_example(7_selections)
diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp
index 5fd0d69cea..c2491b6030 100644
--- a/examples/widgets/tutorials/notepad/notepad.cpp
+++ b/examples/widgets/tutorials/notepad/notepad.cpp
@@ -72,19 +72,24 @@ Notepad::Notepad(QWidget *parent) :
ui(new Ui::Notepad)
{
ui->setupUi(this);
- this->setCentralWidget(ui->textEdit);
connect(ui->actionNew, &QAction::triggered, this, &Notepad::newDocument);
connect(ui->actionOpen, &QAction::triggered, this, &Notepad::open);
connect(ui->actionSave, &QAction::triggered, this, &Notepad::save);
connect(ui->actionSave_as, &QAction::triggered, this, &Notepad::saveAs);
connect(ui->actionPrint, &QAction::triggered, this, &Notepad::print);
- connect(ui->actionExit, &QAction::triggered, this, &Notepad::exit);
- connect(ui->actionCopy, &QAction::triggered, this, &Notepad::copy);
- connect(ui->actionCut, &QAction::triggered, this, &Notepad::cut);
- connect(ui->actionPaste, &QAction::triggered, this, &Notepad::paste);
- connect(ui->actionUndo, &QAction::triggered, this, &Notepad::undo);
- connect(ui->actionRedo, &QAction::triggered, this, &Notepad::redo);
+ connect(ui->actionExit, &QAction::triggered, this, &QWidget::close);
+#if QT_CONFIG(clipboard)
+ connect(ui->textEdit, &QTextEdit::copyAvailable, ui->actionCopy, &QAction::setEnabled);
+ connect(ui->actionCopy, &QAction::triggered, ui->textEdit, &QTextEdit::copy);
+ connect(ui->actionCut, &QAction::triggered, ui->textEdit, &QTextEdit::cut);
+ connect(ui->actionPaste, &QAction::triggered, ui->textEdit, &QTextEdit::paste);
+#endif
+ connect(ui->textEdit, &QTextEdit::undoAvailable, ui->actionUndo, &QAction::setEnabled);
+ connect(ui->actionUndo, &QAction::triggered, ui->textEdit, &QTextEdit::undo);
+ connect(ui->textEdit, &QTextEdit::redoAvailable, ui->actionRedo, &QAction::setEnabled);
+ connect(ui->actionRedo, &QAction::triggered, ui->textEdit, &QTextEdit::redo);
+
connect(ui->actionFont, &QAction::triggered, this, &Notepad::selectFont);
connect(ui->actionBold, &QAction::triggered, this, &Notepad::setFontBold);
connect(ui->actionUnderline, &QAction::triggered, this, &Notepad::setFontUnderline);
@@ -117,6 +122,8 @@ void Notepad::newDocument()
void Notepad::open()
{
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
+ if (fileName.isEmpty())
+ return;
QFile file(fileName);
currentFile = fileName;
if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
@@ -136,6 +143,8 @@ void Notepad::save()
// If we don't have a filename from before, get one.
if (currentFile.isEmpty()) {
fileName = QFileDialog::getSaveFileName(this, "Save");
+ if (fileName.isEmpty())
+ return;
currentFile = fileName;
} else {
fileName = currentFile;
@@ -155,6 +164,8 @@ void Notepad::save()
void Notepad::saveAs()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save as");
+ if (fileName.isEmpty())
+ return;
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
@@ -182,42 +193,6 @@ void Notepad::print()
#endif // QT_CONFIG(printer)
}
-void Notepad::exit()
-{
- QCoreApplication::quit();
-}
-
-void Notepad::copy()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->copy();
-#endif
-}
-
-void Notepad::cut()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->cut();
-#endif
-}
-
-void Notepad::paste()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->paste();
-#endif
-}
-
-void Notepad::undo()
-{
- ui->textEdit->undo();
-}
-
-void Notepad::redo()
-{
- ui->textEdit->redo();
-}
-
void Notepad::selectFont()
{
bool fontSelected;
@@ -244,8 +219,7 @@ void Notepad::setFontBold(bool bold)
void Notepad::about()
{
- QMessageBox::about(this, tr("About MDI"),
- tr("The <b>Notepad</b> example demonstrates how to code a basic "
- "text editor using QtWidgets"));
-
+ QMessageBox::about(this, tr("About Notepad"),
+ tr("The <b>Notepad</b> example demonstrates how to code a basic "
+ "text editor using QtWidgets"));
}
diff --git a/examples/widgets/tutorials/notepad/notepad.h b/examples/widgets/tutorials/notepad/notepad.h
index 5e44dfeedc..d4209daf6d 100644
--- a/examples/widgets/tutorials/notepad/notepad.h
+++ b/examples/widgets/tutorials/notepad/notepad.h
@@ -89,18 +89,6 @@ private slots:
void print();
- void exit();
-
- void copy();
-
- void cut();
-
- void paste();
-
- void undo();
-
- void redo();
-
void selectFont();
void setFontBold(bool bold);
diff --git a/examples/widgets/tutorials/notepad/notepad.ui b/examples/widgets/tutorials/notepad/notepad.ui
index 4b2a6a0675..b891dbae46 100644
--- a/examples/widgets/tutorials/notepad/notepad.ui
+++ b/examples/widgets/tutorials/notepad/notepad.ui
@@ -53,8 +53,15 @@
<addaction name="actionRedo"/>
<addaction name="actionFont"/>
</widget>
+ <widget class="QMenu" name="menuAbout">
+ <property name="title">
+ <string>About</string>
+ </property>
+ <addaction name="actionAbout"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
+ <addaction name="menuAbout"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
@@ -171,8 +178,6 @@
<property name="toolTip">
<string>Exit notepad</string>
</property>
- <property name="shortcut">
- </property>
</action>
<action name="actionCopy">
<property name="icon">
diff --git a/examples/widgets/tutorials/widgets/CMakeLists.txt b/examples/widgets/tutorials/widgets/CMakeLists.txt
index 1f4afee780..fcf0ed9ddd 100644
--- a/examples/widgets/tutorials/widgets/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from widgets.pro.
-add_subdirectory(toplevel)
-add_subdirectory(childwidget)
-add_subdirectory(windowlayout)
-add_subdirectory(nestedlayouts)
+qt_internal_add_example(toplevel)
+qt_internal_add_example(childwidget)
+qt_internal_add_example(windowlayout)
+qt_internal_add_example(nestedlayouts)
diff --git a/examples/widgets/widgets/CMakeLists.txt b/examples/widgets/widgets/CMakeLists.txt
index 8daf6a69ae..34d3d28b67 100644
--- a/examples/widgets/widgets/CMakeLists.txt
+++ b/examples/widgets/widgets/CMakeLists.txt
@@ -1,27 +1,27 @@
# Generated from widgets.pro.
-add_subdirectory(analogclock)
-add_subdirectory(calculator)
-add_subdirectory(calendarwidget)
-add_subdirectory(charactermap)
-add_subdirectory(codeeditor)
-add_subdirectory(digitalclock)
-add_subdirectory(elidedlabel)
-add_subdirectory(groupbox)
-add_subdirectory(icons)
-add_subdirectory(imageviewer)
-add_subdirectory(lineedits)
-add_subdirectory(movie)
-add_subdirectory(mousebuttons)
-add_subdirectory(scribble)
-add_subdirectory(shapedclock)
-add_subdirectory(sliders)
-add_subdirectory(spinboxes)
-add_subdirectory(styles)
-add_subdirectory(stylesheet)
-add_subdirectory(tablet)
-add_subdirectory(tetrix)
-add_subdirectory(tooltips)
-add_subdirectory(validators)
-add_subdirectory(wiggly)
-add_subdirectory(windowflags)
+qt_internal_add_example(analogclock)
+qt_internal_add_example(calculator)
+qt_internal_add_example(calendarwidget)
+qt_internal_add_example(charactermap)
+qt_internal_add_example(codeeditor)
+qt_internal_add_example(digitalclock)
+qt_internal_add_example(elidedlabel)
+qt_internal_add_example(groupbox)
+qt_internal_add_example(icons)
+qt_internal_add_example(imageviewer)
+qt_internal_add_example(lineedits)
+qt_internal_add_example(movie)
+qt_internal_add_example(mousebuttons)
+qt_internal_add_example(scribble)
+qt_internal_add_example(shapedclock)
+qt_internal_add_example(sliders)
+qt_internal_add_example(spinboxes)
+qt_internal_add_example(styles)
+qt_internal_add_example(stylesheet)
+qt_internal_add_example(tablet)
+qt_internal_add_example(tetrix)
+qt_internal_add_example(tooltips)
+qt_internal_add_example(validators)
+qt_internal_add_example(wiggly)
+qt_internal_add_example(windowflags)
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp
index a8bd20e964..6e7bb295e1 100644
--- a/examples/widgets/widgets/stylesheet/mainwindow.cpp
+++ b/examples/widgets/widgets/stylesheet/mainwindow.cpp
@@ -76,10 +76,12 @@ void MainWindow::on_editStyleAction_triggered()
void MainWindow::on_aboutAction_triggered()
{
+ const QString url = QStringLiteral("http://doc.qt.io/qt-%1/stylesheet.html")
+ .arg(QT_VERSION_MAJOR);
QMessageBox::about(this, tr("About Style sheet"),
tr("The <b>Style Sheet</b> example shows how widgets can be styled "
- "using <a href=\"http://doc.qt.io/qt-5/stylesheet.html\">Qt "
+ "using <a href=\"%1\">Qt "
"Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop up the "
"style editor, and either choose an existing style sheet or design "
- "your own."));
+ "your own.").arg(url));
}
diff --git a/examples/xml/CMakeLists.txt b/examples/xml/CMakeLists.txt
index 8e145b4ccb..f9fcacb31c 100644
--- a/examples/xml/CMakeLists.txt
+++ b/examples/xml/CMakeLists.txt
@@ -1,11 +1,11 @@
# Generated from xml.pro.
-add_subdirectory(htmlinfo)
-add_subdirectory(xmlstreamlint)
+qt_internal_add_example(htmlinfo)
+qt_internal_add_example(xmlstreamlint)
if(TARGET Qt::Widgets)
- add_subdirectory(dombookmarks)
- add_subdirectory(streambookmarks)
+ qt_internal_add_example(dombookmarks)
+ qt_internal_add_example(streambookmarks)
endif()
if(TARGET Qt::Network AND TARGET Qt::Widgets)
- add_subdirectory(rsslisting)
+ qt_internal_add_example(rsslisting)
endif()