aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/customitems
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/customitems')
-rw-r--r--examples/quick/customitems/.prev_CMakeLists.txt4
-rw-r--r--examples/quick/customitems/dialcontrol/CMakeLists.txt41
-rw-r--r--examples/quick/customitems/dialcontrol/Dial.qml (renamed from examples/quick/customitems/dialcontrol/content/Dial.qml)0
-rw-r--r--examples/quick/customitems/dialcontrol/QuitButton.qml (renamed from examples/quick/customitems/dialcontrol/content/QuitButton.qml)0
-rw-r--r--examples/quick/customitems/dialcontrol/background.png (renamed from examples/quick/customitems/dialcontrol/content/background.png)bin35876 -> 35876 bytes
-rw-r--r--examples/quick/customitems/dialcontrol/dialcontrol.qml1
-rw-r--r--examples/quick/customitems/dialcontrol/dialcontrol.qrc16
-rw-r--r--examples/quick/customitems/dialcontrol/main.cpp2
-rw-r--r--examples/quick/customitems/dialcontrol/needle.png (renamed from examples/quick/customitems/dialcontrol/content/needle.png)bin342 -> 342 bytes
-rw-r--r--examples/quick/customitems/dialcontrol/needle_shadow.png (renamed from examples/quick/customitems/dialcontrol/content/needle_shadow.png)bin632 -> 632 bytes
-rw-r--r--examples/quick/customitems/dialcontrol/overlay.png (renamed from examples/quick/customitems/dialcontrol/content/overlay.png)bin3564 -> 3564 bytes
-rw-r--r--examples/quick/customitems/dialcontrol/quit.png (renamed from examples/quick/customitems/dialcontrol/content/quit.png)bin583 -> 583 bytes
-rw-r--r--examples/quick/customitems/flipable/5_heart.png (renamed from examples/quick/customitems/flipable/content/5_heart.png)bin3872 -> 3872 bytes
-rw-r--r--examples/quick/customitems/flipable/9_club.png (renamed from examples/quick/customitems/flipable/content/9_club.png)bin6135 -> 6135 bytes
-rw-r--r--examples/quick/customitems/flipable/CMakeLists.txt49
-rw-r--r--examples/quick/customitems/flipable/Card.qml (renamed from examples/quick/customitems/flipable/content/Card.qml)4
-rw-r--r--examples/quick/customitems/flipable/back.png (renamed from examples/quick/customitems/flipable/content/back.png)bin1418 -> 1418 bytes
-rw-r--r--examples/quick/customitems/flipable/flipable.qml9
-rw-r--r--examples/quick/customitems/flipable/flipable.qrc10
-rw-r--r--examples/quick/customitems/flipable/main.cpp4
-rw-r--r--examples/quick/customitems/maskedmousearea/CMakeLists.txt34
-rw-r--r--examples/quick/customitems/painteditem/CMakeLists.txt63
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt30
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/plugin.h (renamed from examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h)2
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/qmldir (renamed from examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir)1
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp (renamed from examples/quick/customitems/painteditem/textballoon.cpp)0
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.h (renamed from examples/quick/customitems/painteditem/textballoon.h)4
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.pro28
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc5
-rw-r--r--examples/quick/customitems/painteditem/doc/src/textballoons.qdoc22
-rw-r--r--examples/quick/customitems/painteditem/main.cpp51
-rw-r--r--examples/quick/customitems/painteditem/painteditem.pro31
-rw-r--r--examples/quick/customitems/painteditem/painteditem.qrc1
-rw-r--r--examples/quick/customitems/painteditem/textballoons.qml2
-rw-r--r--examples/quick/customitems/painteditem/textballoonuser.pro10
-rw-r--r--examples/quick/customitems/scrollbar/ScrollBar.qml14
36 files changed, 272 insertions, 166 deletions
diff --git a/examples/quick/customitems/.prev_CMakeLists.txt b/examples/quick/customitems/.prev_CMakeLists.txt
deleted file mode 100644
index 4afbfe3f6b..0000000000
--- a/examples/quick/customitems/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from customitems.pro.
-
-add_subdirectory(painteditem)
-add_subdirectory(maskedmousearea)
diff --git a/examples/quick/customitems/dialcontrol/CMakeLists.txt b/examples/quick/customitems/dialcontrol/CMakeLists.txt
index 9d2fa2818a..dfc69c3c67 100644
--- a/examples/quick/customitems/dialcontrol/CMakeLists.txt
+++ b/examples/quick/customitems/dialcontrol/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from dialcontrol.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(dialcontrol LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -20,41 +20,36 @@ find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Qml)
-qt_add_executable(dialcontrol
+qt_add_executable(dialcontrolexample
main.cpp
)
-set_target_properties(dialcontrol PROPERTIES
+set_target_properties(dialcontrolexample PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(dialcontrol PUBLIC
+target_link_libraries(dialcontrolexample PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)
-
-# Resources:
-set(dialcontrol_resource_files
- "content/Dial.qml"
- "content/QuitButton.qml"
- "content/background.png"
- "content/needle.png"
- "content/needle_shadow.png"
- "content/overlay.png"
- "content/quit.png"
- "dialcontrol.qml"
-)
-
-qt6_add_resources(dialcontrol "dialcontrol"
- PREFIX
- "/"
- FILES
- ${dialcontrol_resource_files}
+qt_add_qml_module(dialcontrolexample
+ URI dialcontrol
+ VERSION 1.0
+ QML_FILES
+ "Dial.qml"
+ "QuitButton.qml"
+ "dialcontrol.qml"
+ RESOURCES
+ "background.png"
+ "needle.png"
+ "needle_shadow.png"
+ "overlay.png"
+ "quit.png"
)
-install(TARGETS dialcontrol
+install(TARGETS dialcontrolexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quick/customitems/dialcontrol/content/Dial.qml b/examples/quick/customitems/dialcontrol/Dial.qml
index 108b0e7410..108b0e7410 100644
--- a/examples/quick/customitems/dialcontrol/content/Dial.qml
+++ b/examples/quick/customitems/dialcontrol/Dial.qml
diff --git a/examples/quick/customitems/dialcontrol/content/QuitButton.qml b/examples/quick/customitems/dialcontrol/QuitButton.qml
index 87dc159c5d..87dc159c5d 100644
--- a/examples/quick/customitems/dialcontrol/content/QuitButton.qml
+++ b/examples/quick/customitems/dialcontrol/QuitButton.qml
diff --git a/examples/quick/customitems/dialcontrol/content/background.png b/examples/quick/customitems/dialcontrol/background.png
index 75d555d7ab..75d555d7ab 100644
--- a/examples/quick/customitems/dialcontrol/content/background.png
+++ b/examples/quick/customitems/dialcontrol/background.png
Binary files differ
diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qml b/examples/quick/customitems/dialcontrol/dialcontrol.qml
index d0a623a72a..c6bff8f2c0 100644
--- a/examples/quick/customitems/dialcontrol/dialcontrol.qml
+++ b/examples/quick/customitems/dialcontrol/dialcontrol.qml
@@ -51,7 +51,6 @@
//! [imports]
import QtQuick 2.2
import QtQuick.Window 2.1
-import "content"
//! [imports]
//! [0]
diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qrc b/examples/quick/customitems/dialcontrol/dialcontrol.qrc
index 6433d68bb8..9b9bd42f23 100644
--- a/examples/quick/customitems/dialcontrol/dialcontrol.qrc
+++ b/examples/quick/customitems/dialcontrol/dialcontrol.qrc
@@ -1,12 +1,12 @@
<RCC>
- <qresource prefix="/">
+ <qresource prefix="/dialcontrol">
+ <file>Dial.qml</file>
+ <file>QuitButton.qml</file>
+ <file>background.png</file>
<file>dialcontrol.qml</file>
- <file>content/background.png</file>
- <file>content/Dial.qml</file>
- <file>content/needle_shadow.png</file>
- <file>content/needle.png</file>
- <file>content/overlay.png</file>
- <file>content/quit.png</file>
- <file>content/QuitButton.qml</file>
+ <file>needle.png</file>
+ <file>needle_shadow.png</file>
+ <file>overlay.png</file>
+ <file>quit.png</file>
</qresource>
</RCC>
diff --git a/examples/quick/customitems/dialcontrol/main.cpp b/examples/quick/customitems/dialcontrol/main.cpp
index 6ebe203a70..3b925c3d8b 100644
--- a/examples/quick/customitems/dialcontrol/main.cpp
+++ b/examples/quick/customitems/dialcontrol/main.cpp
@@ -48,4 +48,4 @@
**
****************************************************************************/
#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(dialcontrol)
+DECLARATIVE_EXAMPLE_MAIN(dialcontrol/dialcontrol)
diff --git a/examples/quick/customitems/dialcontrol/content/needle.png b/examples/quick/customitems/dialcontrol/needle.png
index 2d19f75039..2d19f75039 100644
--- a/examples/quick/customitems/dialcontrol/content/needle.png
+++ b/examples/quick/customitems/dialcontrol/needle.png
Binary files differ
diff --git a/examples/quick/customitems/dialcontrol/content/needle_shadow.png b/examples/quick/customitems/dialcontrol/needle_shadow.png
index 8d8a928cc5..8d8a928cc5 100644
--- a/examples/quick/customitems/dialcontrol/content/needle_shadow.png
+++ b/examples/quick/customitems/dialcontrol/needle_shadow.png
Binary files differ
diff --git a/examples/quick/customitems/dialcontrol/content/overlay.png b/examples/quick/customitems/dialcontrol/overlay.png
index 3860a7b590..3860a7b590 100644
--- a/examples/quick/customitems/dialcontrol/content/overlay.png
+++ b/examples/quick/customitems/dialcontrol/overlay.png
Binary files differ
diff --git a/examples/quick/customitems/dialcontrol/content/quit.png b/examples/quick/customitems/dialcontrol/quit.png
index b822057d4e..b822057d4e 100644
--- a/examples/quick/customitems/dialcontrol/content/quit.png
+++ b/examples/quick/customitems/dialcontrol/quit.png
Binary files differ
diff --git a/examples/quick/customitems/flipable/content/5_heart.png b/examples/quick/customitems/flipable/5_heart.png
index fb59d81453..fb59d81453 100644
--- a/examples/quick/customitems/flipable/content/5_heart.png
+++ b/examples/quick/customitems/flipable/5_heart.png
Binary files differ
diff --git a/examples/quick/customitems/flipable/content/9_club.png b/examples/quick/customitems/flipable/9_club.png
index 2545001904..2545001904 100644
--- a/examples/quick/customitems/flipable/content/9_club.png
+++ b/examples/quick/customitems/flipable/9_club.png
Binary files differ
diff --git a/examples/quick/customitems/flipable/CMakeLists.txt b/examples/quick/customitems/flipable/CMakeLists.txt
new file mode 100644
index 0000000000..469cde10ee
--- /dev/null
+++ b/examples/quick/customitems/flipable/CMakeLists.txt
@@ -0,0 +1,49 @@
+# Generated from flipable.pro.
+
+cmake_minimum_required(VERSION 3.16)
+
+project(flipable LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/customitems/flipable")
+
+find_package(Qt6 COMPONENTS Core Gui Quick Qml)
+
+qt_add_executable(flipableexample
+ WIN32
+ MACOSX_BUNDLE
+ main.cpp
+)
+
+target_link_libraries(flipableexample PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+)
+
+qt_add_qml_module(flipableexample
+ URI flipable
+ VERSION 1.0
+ QML_FILES
+ "flipable.qml"
+ "Card.qml"
+ RESOURCES
+ "5_heart.png"
+ "9_club.png"
+ "back.png"
+)
+
+install(TARGETS flipableexample
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/quick/customitems/flipable/content/Card.qml b/examples/quick/customitems/flipable/Card.qml
index ffffdb6b7d..bc50bbe473 100644
--- a/examples/quick/customitems/flipable/content/Card.qml
+++ b/examples/quick/customitems/flipable/Card.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick
Flipable {
id: container
diff --git a/examples/quick/customitems/flipable/content/back.png b/examples/quick/customitems/flipable/back.png
index f715d7487e..f715d7487e 100644
--- a/examples/quick/customitems/flipable/content/back.png
+++ b/examples/quick/customitems/flipable/back.png
Binary files differ
diff --git a/examples/quick/customitems/flipable/flipable.qml b/examples/quick/customitems/flipable/flipable.qml
index 3662898864..c22eb841b0 100644
--- a/examples/quick/customitems/flipable/flipable.qml
+++ b/examples/quick/customitems/flipable/flipable.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,8 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.0
-import "content"
+import QtQuick
Rectangle {
id: window
@@ -59,7 +58,7 @@ Rectangle {
Row {
anchors.centerIn: parent; spacing: 30
- Card { source: "content/9_club.png"; angle: 180; yAxis: 1 }
- Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 }
+ Card { source: "9_club.png"; angle: 180; yAxis: 1 }
+ Card { source: "5_heart.png"; angle: 540; xAxis: 1 }
}
}
diff --git a/examples/quick/customitems/flipable/flipable.qrc b/examples/quick/customitems/flipable/flipable.qrc
index 7918ccf00e..b7bc2f3021 100644
--- a/examples/quick/customitems/flipable/flipable.qrc
+++ b/examples/quick/customitems/flipable/flipable.qrc
@@ -1,9 +1,9 @@
<RCC>
- <qresource prefix="/">
+ <qresource prefix="/flipable">
<file>flipable.qml</file>
- <file>content/5_heart.png</file>
- <file>content/9_club.png</file>
- <file>content/back.png</file>
- <file>content/Card.qml</file>
+ <file>5_heart.png</file>
+ <file>9_club.png</file>
+ <file>back.png</file>
+ <file>Card.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/customitems/flipable/main.cpp b/examples/quick/customitems/flipable/main.cpp
index a0f0d67d45..6a4967bc65 100644
--- a/examples/quick/customitems/flipable/main.cpp
+++ b/examples/quick/customitems/flipable/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,4 +48,4 @@
**
****************************************************************************/
#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(flipable)
+DECLARATIVE_EXAMPLE_MAIN(flipable/flipable)
diff --git a/examples/quick/customitems/maskedmousearea/CMakeLists.txt b/examples/quick/customitems/maskedmousearea/CMakeLists.txt
index 0c5a19b5e7..afe52f0a9d 100644
--- a/examples/quick/customitems/maskedmousearea/CMakeLists.txt
+++ b/examples/quick/customitems/maskedmousearea/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from maskedmousearea.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(maskedmousearea LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -35,20 +35,17 @@ target_link_libraries(maskedmousearea PUBLIC
Qt::Quick
)
-
-# Resources:
-set(maskedmousearea_resource_files
- "images/cloud_1.png"
- "images/cloud_2.png"
- "images/moon.png"
- "maskedmousearea.qml"
-)
-
-qt6_add_resources(maskedmousearea "maskedmousearea"
- PREFIX
- "/customitems/maskedmousearea"
- FILES
- ${maskedmousearea_resource_files}
+qt_add_qml_module(maskedmousearea
+ URI Example
+ VERSION 1.0
+ QML_FILES
+ maskedmousearea.qml
+ RESOURCES
+ images/cloud_1.png
+ images/cloud_2.png
+ images/moon.png
+ RESOURCE_PREFIX /customitems/maskedmousearea
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS maskedmousearea
@@ -56,10 +53,3 @@ install(TARGETS maskedmousearea
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(maskedmousearea PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI Example
-)
-
-qt6_qml_type_registration(maskedmousearea)
diff --git a/examples/quick/customitems/painteditem/CMakeLists.txt b/examples/quick/customitems/painteditem/CMakeLists.txt
index 09f3424f15..8299de4882 100644
--- a/examples/quick/customitems/painteditem/CMakeLists.txt
+++ b/examples/quick/customitems/painteditem/CMakeLists.txt
@@ -1,63 +1,46 @@
-# Generated from painteditem.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qmltextballoonplugin LANGUAGES CXX)
+cmake_minimum_required(VERSION 3.16)
+project(painteditem 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}/quick/customitems/painteditem/TextBalloonPlugin")
-set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples/quick/customitems/painteditem)
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/customitems/painteditem")
+
+find_package(Qt6 COMPONENTS Core Gui Quick Qml)
+
+add_subdirectory(TextBalloon)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
+qt_add_executable(painteditemexample WIN32 MACOSX_BUNDLE main.cpp)
-qt6_add_qml_module(qmltextballoonplugin
+qt_add_qml_module(painteditemexample
+ URI painteditem
VERSION 1.0
- URI "TextBalloonPlugin"
- PLUGIN_TARGET qmltextballoonplugin
- QML_FILES textballoons.qml
- RESOURCE_PREFIX "/painteditem"
+ QML_FILES
+ "textballoons.qml"
)
-target_sources(qmltextballoonplugin PRIVATE
- textballoon.cpp textballoon.h
-)
-set_target_properties(qmltextballoonplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(qmltextballoonplugin PUBLIC
+target_link_libraries(painteditemexample PRIVATE
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)
+add_dependencies(painteditemexample qmltextballoon)
-
-# Resources:
-set(painteditem_resource_files
- "textballoon.h"
-)
-
-qt6_add_resources(qmltextballoonplugin "painteditem"
- PREFIX
- "/painteditem"
- FILES
- ${painteditem_resource_files}
-)
-
-install(TARGETS qmltextballoonplugin
+install(TARGETS painteditemexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
+
+include(../../shared/QtBundleQmlModuleForMacOS.cmake)
+
+set(app_target "painteditemexample")
+set(qml_plugin_target "qmltextballoon")
+set(qml_module_uri "TextBalloon")
+add_qml_module_to_macos_app_bundle(
+ "${app_target}" "${qml_plugin_target}" "${qml_module_uri}")
diff --git a/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt b/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt
new file mode 100644
index 0000000000..fb2bf7568e
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt
@@ -0,0 +1,30 @@
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "TextBalloon should be built as part of the 'painteditem' project, and not in isolation.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/customitems/painteditem/TextBalloon")
+
+qt_add_qml_module(qmltextballoon
+ VERSION 1.0
+ URI "TextBalloon"
+ PLUGIN_TARGET qmltextballoon
+ SOURCES
+ textballoon.cpp textballoon.h
+)
+
+target_link_libraries(qmltextballoon PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+)
+
+install(TARGETS qmltextballoon
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h b/examples/quick/customitems/painteditem/TextBalloon/plugin.h
index 4abf2cf3dc..6fabbe0b37 100644
--- a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h
+++ b/examples/quick/customitems/painteditem/TextBalloon/plugin.h
@@ -50,7 +50,7 @@
#include <QQmlEngineExtensionPlugin>
-#include "../textballoon.h"
+#include "textballoon.h"
class TextBalloonPlugin : public QQmlEngineExtensionPlugin
{
diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir b/examples/quick/customitems/painteditem/TextBalloon/qmldir
index e8a08ae9d3..3b72e9a44d 100644
--- a/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir
+++ b/examples/quick/customitems/painteditem/TextBalloon/qmldir
@@ -1 +1,2 @@
+module TextBalloon
plugin qmltextballoonplugin
diff --git a/examples/quick/customitems/painteditem/textballoon.cpp b/examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp
index d3d4246eb2..d3d4246eb2 100644
--- a/examples/quick/customitems/painteditem/textballoon.cpp
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp
diff --git a/examples/quick/customitems/painteditem/textballoon.h b/examples/quick/customitems/painteditem/TextBalloon/textballoon.h
index 129b0f7ee1..520def639e 100644
--- a/examples/quick/customitems/painteditem/textballoon.h
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.h
@@ -61,8 +61,8 @@ class TextBalloon : public QQuickPaintedItem
QML_ELEMENT
public:
- TextBalloon(QQuickItem *parent = 0);
- void paint(QPainter *painter);
+ TextBalloon(QQuickItem *parent = nullptr);
+ void paint(QPainter *painter) override;
bool isRightAligned() const;
void setRightAligned(bool rightAligned);
diff --git a/examples/quick/customitems/painteditem/TextBalloon/textballoon.pro b/examples/quick/customitems/painteditem/TextBalloon/textballoon.pro
new file mode 100644
index 0000000000..7f7662b451
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.pro
@@ -0,0 +1,28 @@
+TEMPLATE = lib
+CONFIG += plugin qmltypes
+QT += qml quick
+
+QML_IMPORT_NAME = TextBalloon
+QML_IMPORT_MAJOR_VERSION = 1
+
+TARGET = qmltextballoonplugin
+
+HEADERS += \
+ plugin.h \
+ textballoon.h
+
+SOURCES += textballoon.cpp
+
+RESOURCES += textballoon.qrc
+
+qmldir_output.files = qmldir
+qmldir_output.path = $$OUT_PWD
+COPIES += qmldir_output
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
+qmldir_install.files = qmldir
+qmldir_install.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
+
+INSTALLS += qmldir_install target
+
+CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc b/examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc
new file mode 100644
index 0000000000..42c42bd0a6
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/TextBalloon">
+ <file>qmldir</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc b/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc
index 4541ba0bd9..57ffd0f6b1 100644
--- a/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc
+++ b/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc
@@ -38,16 +38,14 @@
The QQuickPaintedItem class is a class derived from QQuickItem for implementing
custom QML Scene Graph items using the QPainter interfaces.
- The example consists of an item class, a plugin class and a QML file
- to use this plugin. The \c TextBalloon class represents the individual
- text balloons extending QQuickPaintedItem, the \c TextBalloonPlugin class
- represents the skeleton code for a \l {Qt Quick} plugin and the
- \c textballoons.qml file is used to load the plugin and display the text
- balloons.
+ The example consists of an item class and a QML file to use the item. The
+ \c TextBalloon class represents the individual text balloons extending
+ QQuickPaintedItem and the \c textballoons.qml file is used to load the module
+ containing the TextBalloon QML type and display the text balloons.
We will focus on the \c TextBalloon class first and continue with the
- \c textballoons.qml file. For an example on how to implement a \l {Qt Quick}
- plugin please look at \l{Chapter 6: Writing an Extension Plugin}
+ \c textballoons.qml file. For an example on how to implement a plugin for a
+ QML module please look at \l{Chapter 6: Writing an Extension Plugin}
{Writing an Extension Plugin}
\section1 TextBalloon Class Declaration
@@ -56,7 +54,7 @@
is the base class for all QPainter based items in the QML Scene Graph
framework.
- \snippet customitems/painteditem/textballoon.h 0
+ \snippet customitems/painteditem/TextBalloon/textballoon.h 0
To implement a QQuickPaintedItem you must implement QQuickPaintedIem's pure
virtual function \l {QQuickPaintedItem::}{paint()} which implements the
@@ -67,13 +65,13 @@
We have to be sure to initialize the rightAligned property for a
TextBalloon item.
- \snippet customitems/painteditem/textballoon.cpp 0
+ \snippet customitems/painteditem/TextBalloon/textballoon.cpp 0
Then we implement the \c paint() function which is automatically called by
the Scene Graph framework to paint the contents of the item. The function
paints the item in local coordinates.
- \snippet customitems/painteditem/textballoon.cpp 1
+ \snippet customitems/painteditem/TextBalloon/textballoon.cpp 1
We start with setting the pen and brush on the item to define the look of
the item. After that we start drawing. Note that the \l {QQuickPaintedItem::}{contentsBoundingRect()}
@@ -81,7 +79,7 @@
returned by the \l {QQuickPaintedItem::}{contentsBoundingRect()} function is the size
of the item as defined in the QML file.
- \section1 Textballoons.qml File
+ \section1 textballoons.qml File
The Interface consists of two main parts. The scrollable area with the
textballoons and the controls button to add new balloons.
diff --git a/examples/quick/customitems/painteditem/main.cpp b/examples/quick/customitems/painteditem/main.cpp
new file mode 100644
index 0000000000..7f01df3395
--- /dev/null
+++ b/examples/quick/customitems/painteditem/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(painteditem/textballoons)
diff --git a/examples/quick/customitems/painteditem/painteditem.pro b/examples/quick/customitems/painteditem/painteditem.pro
index 641833f3aa..7c26304b26 100644
--- a/examples/quick/customitems/painteditem/painteditem.pro
+++ b/examples/quick/customitems/painteditem/painteditem.pro
@@ -1,29 +1,2 @@
-TEMPLATE = lib
-CONFIG += plugin qmltypes
-QT += qml quick
-
-QML_IMPORT_NAME = TextBalloonPlugin
-QML_IMPORT_MAJOR_VERSION = 1
-
-TARGET = qmltextballoonplugin
-
-HEADERS += \
- TextBalloonPlugin/plugin.h \
- textballoon.h
-
-SOURCES += textballoon.cpp
-
-RESOURCES += painteditem.qrc
-
-DESTDIR = $$QML_IMPORT_NAME
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
-qmldir.files = $$QML_IMPORT_NAME/qmldir
-qmldir.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
-
-INSTALLS += qmldir target
-
-CONFIG += install_ok # Do not cargo-cult this!
-
-OTHER_FILES += \
- textballoons.qml
+TEMPLATE = subdirs
+SUBDIRS = TextBalloon/textballoon.pro textballoonuser.pro
diff --git a/examples/quick/customitems/painteditem/painteditem.qrc b/examples/quick/customitems/painteditem/painteditem.qrc
index c240be02a1..d436ab32e2 100644
--- a/examples/quick/customitems/painteditem/painteditem.qrc
+++ b/examples/quick/customitems/painteditem/painteditem.qrc
@@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/painteditem">
- <file>textballoon.h</file>
<file>textballoons.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/customitems/painteditem/textballoons.qml b/examples/quick/customitems/painteditem/textballoons.qml
index 2c749bb440..c520dda271 100644
--- a/examples/quick/customitems/painteditem/textballoons.qml
+++ b/examples/quick/customitems/painteditem/textballoons.qml
@@ -49,7 +49,7 @@
****************************************************************************/
import QtQuick 2.0
-import "TextBalloonPlugin" 1.0
+import TextBalloon 1.0
Item {
height: 480
diff --git a/examples/quick/customitems/painteditem/textballoonuser.pro b/examples/quick/customitems/painteditem/textballoonuser.pro
new file mode 100644
index 0000000000..7504542f4c
--- /dev/null
+++ b/examples/quick/customitems/painteditem/textballoonuser.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += qml quick
+
+TARGET = painteditem
+SOURCES += main.cpp
+RESOURCES += painteditem.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem
+INSTALLS += target
diff --git a/examples/quick/customitems/scrollbar/ScrollBar.qml b/examples/quick/customitems/scrollbar/ScrollBar.qml
index f2e46c5681..655335d78c 100644
--- a/examples/quick/customitems/scrollbar/ScrollBar.qml
+++ b/examples/quick/customitems/scrollbar/ScrollBar.qml
@@ -60,24 +60,24 @@ Item {
// orientation can be either Qt.Vertical or Qt.Horizontal
property real position
property real pageSize
- property variant orientation : Qt.Vertical
+ property int orientation : Qt.Vertical
// A light, semi-transparent background
Rectangle {
id: background
anchors.fill: parent
- radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
+ radius: orientation === Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
color: "white"
opacity: 0.3
}
// Size the bar to the required size, depending upon the orientation.
Rectangle {
- x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
- y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
- width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
- height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
- radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
+ x: orientation === Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
+ y: orientation === Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
+ width: orientation === Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
+ height: orientation === Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ radius: orientation === Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
color: "black"
opacity: 0.7
}