summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-08 10:27:41 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-08 21:41:42 +0100
commit1f859ca1ac6d337aedde2fe8eed74266416ae0d1 (patch)
treebd671a975109a2c5fb8e5622e8cc8572af4a694e /examples
parent87fac2de7378963e753a847da667d52d4ba95bff (diff)
downloadqttools-1f859ca1ac6d337aedde2fe8eed74266416ae0d1.tar.gz
Qt Designer: Remove worldtimeclock examples
The functionality is sufficiently demonstrated by the existing custom widget plugin examples. Task-number: QTBUG-110447 Pick-to: 6.5 Change-Id: I09198bba46ebe8da03c9e21192588e6010bec541 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/designer/CMakeLists.txt2
-rw-r--r--examples/designer/customwidgetplugin/analogclock.h4
-rw-r--r--examples/designer/designer.pro4
-rw-r--r--examples/designer/doc/snippets/doc_src_examples_worldtimeclockplugin.pro7
-rw-r--r--examples/designer/doc/src/worldtimeclockbuilder.qdoc73
-rw-r--r--examples/designer/doc/src/worldtimeclockplugin.qdoc182
-rw-r--r--examples/designer/worldtimeclockbuilder/CMakeLists.txt52
-rw-r--r--examples/designer/worldtimeclockbuilder/form.ui162
-rw-r--r--examples/designer/worldtimeclockbuilder/main.cpp36
-rw-r--r--examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro8
-rw-r--r--examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc5
-rw-r--r--examples/designer/worldtimeclockplugin/CMakeLists.txt53
-rw-r--r--examples/designer/worldtimeclockplugin/worldtimeclock.cpp77
-rw-r--r--examples/designer/worldtimeclockplugin/worldtimeclock.h35
-rw-r--r--examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp85
-rw-r--r--examples/designer/worldtimeclockplugin/worldtimeclockplugin.h39
-rw-r--r--examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro31
17 files changed, 5 insertions, 850 deletions
diff --git a/examples/designer/CMakeLists.txt b/examples/designer/CMakeLists.txt
index 32848c69e..b98f6ea5f 100644
--- a/examples/designer/CMakeLists.txt
+++ b/examples/designer/CMakeLists.txt
@@ -9,11 +9,9 @@ qt_exclude_tool_directories_from_default_target(
qt_internal_add_example(calculatorform)
if(QT_BUILD_SHARED_LIBS AND NOT solaris-cc_x_)
qt_internal_add_example(calculatorbuilder)
- qt_internal_add_example(worldtimeclockbuilder)
endif()
if(QT_BUILD_SHARED_LIBS AND NOT CMAKE_CROSSCOMPILING)
qt_internal_add_example(containerextension)
qt_internal_add_example(customwidgetplugin)
qt_internal_add_example(taskmenuextension)
- qt_internal_add_example(worldtimeclockplugin)
endif()
diff --git a/examples/designer/customwidgetplugin/analogclock.h b/examples/designer/customwidgetplugin/analogclock.h
index 073f99e71..c3eabf584 100644
--- a/examples/designer/customwidgetplugin/analogclock.h
+++ b/examples/designer/customwidgetplugin/analogclock.h
@@ -7,15 +7,19 @@
#include <QWidget>
#include <QtUiPlugin/QDesignerExportWidget>
+//! [0]
class QDESIGNER_WIDGET_EXPORT AnalogClock : public QWidget
{
Q_OBJECT
+//! [0]
public:
explicit AnalogClock(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *event) override;
+//! [1]
};
+//! [1]
#endif
diff --git a/examples/designer/designer.pro b/examples/designer/designer.pro
index e7a668195..5f9cc2769 100644
--- a/examples/designer/designer.pro
+++ b/examples/designer/designer.pro
@@ -5,9 +5,7 @@ SUBDIRS = calculatorform
SUBDIRS += calculatorbuilder \
containerextension \
customwidgetplugin \
- taskmenuextension \
- worldtimeclockbuilder \
- worldtimeclockplugin
+ taskmenuextension
}
# the sun cc compiler has a problem with the include lines for the form.prf
diff --git a/examples/designer/doc/snippets/doc_src_examples_worldtimeclockplugin.pro b/examples/designer/doc/snippets/doc_src_examples_worldtimeclockplugin.pro
deleted file mode 100644
index 903cef948..000000000
--- a/examples/designer/doc/snippets/doc_src_examples_worldtimeclockplugin.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#! [0]
-target.path = $$[QT_INSTALL_PLUGINS]/designer
-INSTALLS += target
-#! [0]
diff --git a/examples/designer/doc/src/worldtimeclockbuilder.qdoc b/examples/designer/doc/src/worldtimeclockbuilder.qdoc
deleted file mode 100644
index b732054b0..000000000
--- a/examples/designer/doc/src/worldtimeclockbuilder.qdoc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example worldtimeclockbuilder
- \ingroup examples-designer
- \title World Time Clock Builder Example
-
- \brief Creating forms with Qt Designer that contain custom widgets that can be
- dynamically generated at run-time.
-
- \image worldtimeclockbuilder-example.png
-
- This example uses a form containing the custom widget plugin described in the
- \l{worldtimeclockplugin}{World Time Clock Plugin} example, and
- dynamically generates a user interface using the QUiLoader class, part of
- the QtUiTools module.
-
- \section1 Preparation
-
- As with the \l{calculatorbuilder}{Calculator Builder} example, the
- project file for this example needs to include the appropriate definitions
- to ensure that it is built against the required Qt modules.
-
- \snippet worldtimeclockbuilder/worldtimeclockbuilder.pro 0
-
- By appending \c form to the \c CONFIG declaration, we instruct \c qmake to
- generate a dependency on the \c libQtUiTools library containing the QtUiTools
- classes.
-
- Note that we do not inform \c qmake about any UI files, and so none will
- be processed and built into the application. The resource file contains
- an entry for the particular form that we wish to use:
-
- \quotefile worldtimeclockbuilder/worldtimeclockbuilder.qrc
-
- Forms do not need to be included with the application in this way. We only
- include a form in the application's resources for convenience, and to keep
- the example short.
-
- \section1 Loading and Building the Form
-
- Since this example only loads and displays a pre-prepared form, all of the
- work can be done in the main() function. We are using a class from the
- QtUiTools library so, in addition to any other Qt classes that are normally
- required to write an application, we must include the appropriate header
- file:
-
- \snippet worldtimeclockbuilder/main.cpp 0
-
- The main function initializes the resource system with the Q_INIT_RESOURCE()
- macro and constructs an QApplication instance in the usual way:
-
- \snippet worldtimeclockbuilder/main.cpp 1
-
- We construct a QUiLoader object to handle the form we want to use.
-
- The form itself is obtained from the resource file system using the path
- defined in the resource file. We use the form loader to load and construct
- the form:
-
- \snippet worldtimeclockbuilder/main.cpp 2
-
- Once the form has been loaded, the resource file can be closed and the
- widget is shown.
-
- \snippet worldtimeclockbuilder/main.cpp 3
-
- The form loader ensures that all the signal and slot connections between
- objects in the form are set up correctly when the form is loaded. As a
- result, the time is updated by the World Time Clock widget, and the time
- zone spin box can be used to change the position of the hour hand.
-*/
diff --git a/examples/designer/doc/src/worldtimeclockplugin.qdoc b/examples/designer/doc/src/worldtimeclockplugin.qdoc
deleted file mode 100644
index 25198f261..000000000
--- a/examples/designer/doc/src/worldtimeclockplugin.qdoc
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example worldtimeclockplugin
- \ingroup examples-designer
- \title World Time Clock Plugin Example
-
- \brief Creating a custom widget plugin for \QD that uses signals and slots.
-
- \image worldtimeclockplugin-example.png
-
- In this example, we simply extend the \l
- {customwidgetplugin}{Custom Widget Plugin} example and
- its custom widget (based on the \l{widgets/analogclock}{Analog
- Clock} example), by introducing the concept of signals and slots.
-
- The World Time Clock Plugin example consists of two classes:
-
- \list
- \li \c WorldTimeClock is a custom clock widget with hour and
- minute hands that is automatically updated every few seconds.
- \li \c WorldTimeClockPlugin exposes the \c WorldTimeClock class to \QD.
- \endlist
-
- First we will take a look at the \c WorldTimeClock class which
- extends the \l {customwidgetplugin}{Custom Widget Plugin}
- example's \c AnalogClock class by providing a signal and a
- slot. Then we will take a quick look at the \c
- WorldTimeClockPlugin class, but this class is in most parts
- identical to the \l {customwidgetplugin}{Custom Widget
- Plugin} example's implementation.
-
- Finally we take a look at the plugin's project file. The project
- file for custom widget plugins needs some additional information
- to ensure that they will work within \QD. This is also covered in
- the \l {customwidgetplugin}{Custom Widget Plugin} example,
- but due to its importance (custom widget plugins rely on
- components supplied with \QD which must be specified in the
- project file that we use) we will repeat it here.
-
- \section1 WorldTimeClock Class
-
- The \c WorldTimeClock class inherits QWidget, and is a custom
- clock widget with hour and minute hands that is automatically
- updated every few seconds. What makes this example different from
- the \l {customwidgetplugin}{Custom Widget Plugin}
- example, is the introduction of the signal and slot in the custom
- widget class:
-
- \snippet worldtimeclockplugin/worldtimeclock.h 1
-
- Note the use of the QDESIGNER_WIDGET_EXPORT macro. This is needed
- to ensure that \QD can create instances of the widget on some
- platforms, but it is a good idea to use it on all platforms.
-
- We declare the \c setTimeZone() slot with an associated \c
- timeZoneOffset variable, and we declare an \c updated() signal
- which takes the current time as argument and is emitted whenever
- the widget is repainted.
-
- \image worldtimeclock-connection.png
-
- In \QD's workspace we can then, for example, connect the \c
- WorldTimeClock widget's \c updated() signal to a QTimeEdit's \l
- {QDateTimeEdit::setTime()}{setTime()} slot using \QD's mode
- for editing signal and slots.
-
- \image worldtimeclock-signalandslot.png
-
- We can also connect a QSpinBox's \l
- {QSpinBox::valueChanged()}{valueChanged()} signal to the \c
- WorldTimeClock's \c setTimeZone() slot.
-
- \section1 WorldTimeClockPlugin Class
-
- The \c WorldTimeClockPlugin class exposes the \c WorldTimeClock
- class to \QD. Its definition is equivalent to the \l
- {customwidgetplugin}{Custom Widget Plugin} example's
- plugin class which is explained in detail. The only part of the
- class definition that is specific to this particular custom widget
- is the class name.
-
- To ensure that Qt recognizes the widget as a plugin, export relevant
- information about the widget by adding the \c Q_PLUGIN_METADATA() macro:
-
- \snippet worldtimeclockplugin/worldtimeclockplugin.h 0
-
- The plugin class provides \QD with basic information about our
- plugin, such as its class name and its include file. Furthermore
- it knows how to create instances of the \c WorldTimeClockPlugin
- widget. \c WorldTimeClockPlugin also defines the \l
- {QDesignerCustomWidgetInterface::initialize()}{initialize()}
- function which is called after the plugin is loaded into \QD. The
- function's QDesignerFormEditorInterface parameter provides the
- plugin with a gateway to all of \QD's API's.
-
- The \c WorldTimeClockPlugin class inherits from both QObject and
- QDesignerCustomWidgetInterface. It is important to remember, when
- using multiple inheritance, to ensure that all the interfaces
- (i.e. the classes that doesn't inherit Q_OBJECT) are made known to
- the meta object system using the Q_INTERFACES() macro. This
- enables \QD to use qobject_cast() to query for supported
- interfaces using nothing but a QObject pointer.
-
- The implementation of the \c WorldTimeClockPlugin is also
- equivalent to the plugin interface implementation in the \l
- {customwidgetplugin}{Custom Widget Plugin} example (only
- the class name and the implementation of
- QDesignerCustomWidgetInterface::domXml() differ). The main thing
- to remember is to use the Q_PLUGIN_METADATA() macro to export the \c
- WorldTimeClockPlugin class for use with \QD:
-
- \snippet worldtimeclockplugin/worldtimeclockplugin.h 1
-
- Without this macro, there is no way for Qt Designer to use the
- widget.
-
- \section1 Project files
- \section2 CMake
-
- The project files need to state that a plugin linking
- to the \QD libraries is to be built:
-
- \snippet worldtimeclockplugin/CMakeLists.txt 0
- \codeline
- \snippet worldtimeclockplugin/CMakeLists.txt 2
-
- The link libraries list specifies \c Qt::UiPlugin. This indicates that
- the plugin uses the abstract interfaces QDesignerCustomWidgetInterface
- and QDesignerCustomWidgetCollectionInterface only and has no linkage
- to the \QD libraries. When accessing other interfaces of \QD that have
- linkage, \c Designer should be used instead; this ensures that the plugin
- dynamically links to the \QD libraries and has a run-time dependency on
- them.
-
- The header and source files for the widget are declared in the
- usual way:
-
- \snippet worldtimeclockplugin/CMakeLists.txt 1
-
- We provide an implementation of the plugin interface so that \QD
- can use the custom widget. In this particular example we also
- provide implementations of the container extension interface and
- the extension factory.
-
- It is important to ensure that the plugin is installed in a
- location that is searched by \QD. We do this by specifying a
- target path for the project and adding it to the list of items to
- install:
-
- \snippet worldtimeclockplugin/CMakeLists.txt 3
- \snippet worldtimeclockplugin/CMakeLists.txt 4
-
- The custom widget is created as a library. It will be
- installed alongside the other \QD plugins when the project is
- installed (using \c{ninja install} or an equivalent installation
- procedure).
-
- For more information about plugins, see the
- \l {How to Create Qt Plugins} documentation.
-
- \section2 qmake
-
- The following example shows how to link a plugin to the \QD libraries:
-
- \snippet worldtimeclockplugin/worldtimeclockplugin.pro 0
- \codeline
- \snippet worldtimeclockplugin/worldtimeclockplugin.pro 1
-
- The \c QT variable contains the keyword \c uiplugin, which is
- the equivalent of the \c Qt::UiPlugin library.
-
- The following example shows how to add the header and source files of the
- widget:
-
- \snippet worldtimeclockplugin/worldtimeclockplugin.pro 2
-
- The following example shows how to install a plugin to the \QD's plugin path:
-
- \snippet worldtimeclockplugin/worldtimeclockplugin.pro 3
-*/
diff --git a/examples/designer/worldtimeclockbuilder/CMakeLists.txt b/examples/designer/worldtimeclockbuilder/CMakeLists.txt
deleted file mode 100644
index 8016d9505..000000000
--- a/examples/designer/worldtimeclockbuilder/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(worldtimeclockbuilder LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/designer/worldtimeclockbuilder")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui UiTools Widgets)
-
-qt_add_executable(worldtimeclockbuilder
- main.cpp
-)
-
-set_target_properties(worldtimeclockbuilder PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(worldtimeclockbuilder PUBLIC
- Qt::Core
- Qt::Gui
- Qt::UiTools
- Qt::Widgets
-)
-
-# Resources:
-set(worldtimeclockbuilder_resource_files
- "form.ui"
-)
-
-qt6_add_resources(worldtimeclockbuilder "worldtimeclockbuilder"
- PREFIX
- "/forms"
- FILES
- ${worldtimeclockbuilder_resource_files}
-)
-
-install(TARGETS worldtimeclockbuilder
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/designer/worldtimeclockbuilder/form.ui b/examples/designer/worldtimeclockbuilder/form.ui
deleted file mode 100644
index e5be1d911..000000000
--- a/examples/designer/worldtimeclockbuilder/form.ui
+++ /dev/null
@@ -1,162 +0,0 @@
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>WorldTimeForm</class>
- <widget class="QWidget" name="WorldTimeForm" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>World Time Clock</string>
- </property>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="WorldTimeClock" name="worldTimeClock" />
- </item>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>1</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>1</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Current time:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTimeEdit" name="timeEdit" >
- <property name="readOnly" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>1</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>Set time zone:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="spinBox" >
- <property name="maximum" >
- <number>12</number>
- </property>
- <property name="minimum" >
- <number>-12</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <pixmapfunction></pixmapfunction>
- <customwidgets>
- <customwidget>
- <class>WorldTimeClock</class>
- <extends></extends>
- <header>worldtimeclock.h</header>
- <container>0</container>
- <pixmap></pixmap>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections>
- <connection>
- <sender>spinBox</sender>
- <signal>valueChanged(int)</signal>
- <receiver>worldTimeClock</receiver>
- <slot>setTimeZone(int)</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>339</x>
- <y>166</y>
- </hint>
- <hint type="destinationlabel" >
- <x>157</x>
- <y>230</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>worldTimeClock</sender>
- <signal>updated(QTime)</signal>
- <receiver>timeEdit</receiver>
- <slot>setTime(QTime)</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>141</x>
- <y>59</y>
- </hint>
- <hint type="destinationlabel" >
- <x>291</x>
- <y>133</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/designer/worldtimeclockbuilder/main.cpp b/examples/designer/worldtimeclockbuilder/main.cpp
deleted file mode 100644
index 18e879052..000000000
--- a/examples/designer/worldtimeclockbuilder/main.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-//! [0]
-#include <QtUiTools>
-//! [0]
-#include <QApplication>
-#include <QWidget>
-#include <QFile>
-
-using namespace Qt::StringLiterals;
-
-//! [1]
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(worldtimeclockbuilder);
-
- QApplication app(argc, argv);
-
- QUiLoader loader;
-//! [1]
-
-//! [2]
- QFile file(u":/forms/form.ui"_s);
- file.open(QFile::ReadOnly);
-
- QWidget *widget = loader.load(&file);
-
- file.close();
- widget->show();
-//! [2]
-
-//! [3]
- return app.exec();
-}
-//! [3]
diff --git a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro
deleted file mode 100644
index 1e420aa65..000000000
--- a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-#! [0]
-QT += widgets uitools
-SOURCES = main.cpp
-RESOURCES = worldtimeclockbuilder.qrc
-#! [0]
-
-target.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockbuilder
-INSTALLS += target
diff --git a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc
deleted file mode 100644
index 89d5ac3c2..000000000
--- a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/forms">
- <file>form.ui</file>
-</qresource>
-</RCC>
diff --git a/examples/designer/worldtimeclockplugin/CMakeLists.txt b/examples/designer/worldtimeclockplugin/CMakeLists.txt
deleted file mode 100644
index d532af311..000000000
--- a/examples/designer/worldtimeclockplugin/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(worldtimeclockplugin LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-#! [0]
-find_package(Qt6 REQUIRED COMPONENTS Core Gui UiPlugin Widgets)
-
-qt_add_plugin(worldtimeclockplugin)
-#! [0]
-
-#! [1]
-target_sources(worldtimeclockplugin PRIVATE
- worldtimeclock.cpp worldtimeclock.h
- worldtimeclockplugin.cpp worldtimeclockplugin.h
-)
-#! [1]
-
-set_target_properties(worldtimeclockplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-#! [2]
-target_link_libraries(worldtimeclockplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::UiPlugin
- Qt::Widgets
-)
-#! [2]
-
-if(QT6_INSTALL_PREFIX)
-#! [3]
- set(INSTALL_EXAMPLEDIR "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_PLUGINS}/designer")
-#! [3]
-else()
- if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
- endif()
- set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/plugins/designer")
-endif()
-
-#! [4]
-install(TARGETS worldtimeclockplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
-#! [4]
diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.cpp b/examples/designer/worldtimeclockplugin/worldtimeclock.cpp
deleted file mode 100644
index c3190d275..000000000
--- a/examples/designer/worldtimeclockplugin/worldtimeclock.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "worldtimeclock.h"
-
-#include <QMouseEvent>
-#include <QPainter>
-
-#include <QTimer>
-
-WorldTimeClock::WorldTimeClock(QWidget *parent)
- : QWidget(parent)
-{
- QTimer *timer = new QTimer(this);
- connect(timer, &QTimer::timeout, this, qOverload<>(&QWidget::update));
- timer->start(1000);
-
- setWindowTitle(tr("World Time Clock"));
- resize(200, 200);
-}
-
-void WorldTimeClock::paintEvent(QPaintEvent *)
-{
- static const QPoint hourHand[3] = {{7, 8}, {-7, 8}, {0, -40}};
- static const QPoint minuteHand[3] = {{7, 8}, {-7, 8}, {0, -70}};
-
- QColor hourColor(127, 0, 127);
- QColor minuteColor(0, 127, 127, 191);
-
- int side = qMin(width(), height());
- QTime time = QTime::currentTime();
- time = time.addSecs(timeZoneOffset);
-
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing);
- painter.translate(width() / 2, height() / 2);
- painter.scale(side / 200.0, side / 200.0);
-
- painter.setPen(Qt::NoPen);
- painter.setBrush(hourColor);
-
- painter.save();
- painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
- painter.drawConvexPolygon(hourHand, 3);
- painter.restore();
-
- painter.setPen(hourColor);
-
- for (int i = 0; i < 12; ++i) {
- painter.drawLine(88, 0, 96, 0);
- painter.rotate(30.0);
- }
-
- painter.setPen(Qt::NoPen);
- painter.setBrush(minuteColor);
-
- painter.save();
- painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
- painter.drawConvexPolygon(minuteHand, 3);
- painter.restore();
-
- painter.setPen(minuteColor);
-
- for (int j = 0; j < 60; ++j) {
- if ((j % 5) != 0)
- painter.drawLine(92, 0, 96, 0);
- painter.rotate(6.0);
- }
-
- emit updated(time);
-}
-
-void WorldTimeClock::setTimeZone(int hourOffset)
-{
- timeZoneOffset = qMin(qMax(-12, hourOffset), 12) * 3600;
- update();
-}
diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.h b/examples/designer/worldtimeclockplugin/worldtimeclock.h
deleted file mode 100644
index 10682e8bf..000000000
--- a/examples/designer/worldtimeclockplugin/worldtimeclock.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WORLDTIMECLOCK_H
-#define WORLDTIMECLOCK_H
-
-#include <QTime>
-#include <QWidget>
-#include <QtUiPlugin/QDesignerExportWidget>
-
-//! [0] //! [1]
-class QDESIGNER_WIDGET_EXPORT WorldTimeClock : public QWidget
-{
- Q_OBJECT
-//! [0]
-
-public:
- explicit WorldTimeClock(QWidget *parent = nullptr);
-
-public slots:
- void setTimeZone(int hourOffset);
-
-signals:
- void updated(QTime currentTime);
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-private:
- int timeZoneOffset = 0;
-//! [2]
-};
-//! [1] //! [2]
-
-#endif
diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp
deleted file mode 100644
index 4a52c3961..000000000
--- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "worldtimeclock.h"
-#include "worldtimeclockplugin.h"
-
-#include <QtPlugin>
-
-using namespace Qt::StringLiterals;
-
-WorldTimeClockPlugin::WorldTimeClockPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-void WorldTimeClockPlugin::initialize(QDesignerFormEditorInterface * /* core */)
-{
- if (initialized)
- return;
-
- initialized = true;
-}
-
-bool WorldTimeClockPlugin::isInitialized() const
-{
- return initialized;
-}
-
-QWidget *WorldTimeClockPlugin::createWidget(QWidget *parent)
-{
- return new WorldTimeClock(parent);
-}
-
-QString WorldTimeClockPlugin::name() const
-{
- return u"WorldTimeClock"_s;
-}
-
-QString WorldTimeClockPlugin::group() const
-{
- return u"Display Widgets [Examples]"_s;
-}
-
-QIcon WorldTimeClockPlugin::icon() const
-{
- return {};
-}
-
-QString WorldTimeClockPlugin::toolTip() const
-{
- return {};
-}
-
-QString WorldTimeClockPlugin::whatsThis() const
-{
- return {};
-}
-
-bool WorldTimeClockPlugin::isContainer() const
-{
- return false;
-}
-
-QString WorldTimeClockPlugin::domXml() const
-{
- return uR"(
-<ui language="c++">
- <widget class="WorldTimeClock" name="worldTimeClock">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>100</width>
- <height>100</height>
- </rect>
- </property>
- </widget>
-</ui>
-)"_s;
-}
-
-QString WorldTimeClockPlugin::includeFile() const
-{
- return u"worldtimeclock.h"_s;
-}
diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h
deleted file mode 100644
index 3f7b4b80f..000000000
--- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WORLDTIMECLOCKPLUGIN_H
-#define WORLDTIMECLOCKPLUGIN_H
-
-#include <QtUiPlugin/QDesignerCustomWidgetInterface>
-
-//! [0]
-class WorldTimeClockPlugin : public QObject,
- public QDesignerCustomWidgetInterface
-{
- Q_OBJECT
-//! [1]
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
-//! [1]
- Q_INTERFACES(QDesignerCustomWidgetInterface)
-
-public:
- explicit WorldTimeClockPlugin(QObject *parent = nullptr);
-
- bool isContainer() const override;
- bool isInitialized() const override;
- QIcon icon() const override;
- QString domXml() const override;
- QString group() const override;
- QString includeFile() const override;
- QString name() const override;
- QString toolTip() const override;
- QString whatsThis() const override;
- QWidget *createWidget(QWidget *parent) override;
- void initialize(QDesignerFormEditorInterface *core) override;
-
-private:
- bool initialized = false;
-};
-//! [0]
-
-#endif
diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro
deleted file mode 100644
index dc9331be4..000000000
--- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro
+++ /dev/null
@@ -1,31 +0,0 @@
-#! [1]
-QT += widgets uiplugin
-#! [1]
-
-QTDIR_build {
-# This is only for the Qt build. Do not use externally. We mean it.
-PLUGIN_TYPE = designer
-PLUGIN_CLASS_NAME = WorldTimeClockPlugin
-load(qt_plugin)
-CONFIG += install_ok
-} else {
-# Public example:
-
-TARGET = $$qtLibraryTarget($$TARGET)
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-#! [0]
-
-#! [3]
-target.path = $$[QT_INSTALL_PLUGINS]/designer
-INSTALLS += target
-#! [3]
-}
-
-#! [2]
-HEADERS = worldtimeclock.h \
- worldtimeclockplugin.h
-SOURCES = worldtimeclock.cpp \
- worldtimeclockplugin.cpp
-#! [2]