diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-02-09 12:55:08 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-02-10 10:12:35 +0100 |
commit | db7a30bd1dca12b04f04a2617d54e22c61e5cf70 (patch) | |
tree | fbbda6334d1ba4602bc3316bb93c1c750b40977b /examples/uitools | |
parent | ac8cc15fe727a219da3b6dcd345a9976d2945f09 (diff) | |
download | qttools-db7a30bd1dca12b04f04a2617d54e22c61e5cf70.tar.gz |
Move the uitools multipleinheritance example to calculatorform_mi
It illustrates how to use multipleinheritance from Ui struct and widget
and is not really related to UiTools.
Task-number: QTBUG-110447
Pick-to: 6.5
Change-Id: If6b61c76ea0ac07b935f1e0a8ee02a2e7179cdc3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'examples/uitools')
-rw-r--r-- | examples/uitools/CMakeLists.txt | 1 | ||||
-rw-r--r-- | examples/uitools/doc/images/multipleinheritance-example.png | bin | 6974 -> 0 bytes | |||
-rw-r--r-- | examples/uitools/doc/src/multipleinheritance.qdoc | 72 | ||||
-rw-r--r-- | examples/uitools/multipleinheritance/CMakeLists.txt | 38 | ||||
-rw-r--r-- | examples/uitools/multipleinheritance/calculatorform.cpp | 28 | ||||
-rw-r--r-- | examples/uitools/multipleinheritance/calculatorform.h | 25 | ||||
-rw-r--r-- | examples/uitools/multipleinheritance/calculatorform.ui | 303 | ||||
-rw-r--r-- | examples/uitools/multipleinheritance/main.cpp | 15 | ||||
-rw-r--r-- | examples/uitools/multipleinheritance/multipleinheritance.pro | 11 | ||||
-rw-r--r-- | examples/uitools/uitools.pro | 4 |
10 files changed, 1 insertions, 496 deletions
diff --git a/examples/uitools/CMakeLists.txt b/examples/uitools/CMakeLists.txt index 4720af772..16d288cbc 100644 --- a/examples/uitools/CMakeLists.txt +++ b/examples/uitools/CMakeLists.txt @@ -1,2 +1 @@ -qt_internal_add_example(multipleinheritance) qt_internal_add_example(textfinder) diff --git a/examples/uitools/doc/images/multipleinheritance-example.png b/examples/uitools/doc/images/multipleinheritance-example.png Binary files differdeleted file mode 100644 index 9e8929297..000000000 --- a/examples/uitools/doc/images/multipleinheritance-example.png +++ /dev/null diff --git a/examples/uitools/doc/src/multipleinheritance.qdoc b/examples/uitools/doc/src/multipleinheritance.qdoc deleted file mode 100644 index 1c4a83f37..000000000 --- a/examples/uitools/doc/src/multipleinheritance.qdoc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example multipleinheritance - \ingroup examples-qtuitools - \title Multiple Inheritance Example - - \brief Using a form created with Qt Designer in an application. - - The Multiple Inheritance Example shows how to use a form created with - \l{Qt Designer} in an application by subclassing both QWidget and the user - interface class, which is \c{Ui::CalculatorForm}. - - \image multipleinheritance-example.png - - To subclass the \c calculatorform.ui file and ensure that \c qmake - processes it with the \c uic, we have to include \c calculatorform.ui - in the \c .pro file, as shown below: - - \snippet multipleinheritance/multipleinheritance.pro 0 - - When the project is compiled, the \c uic will generate a corresponding - \c ui_calculatorform.h. - - \section1 CalculatorForm Definition - - In the \c CalculatorForm definition, we include the \c ui_calculatorform.h - that was generated earlier. - - \snippet multipleinheritance/calculatorform.h 0 - - As mentioned earlier, the class is a subclass of both QWidget and - \c{Ui::CalculatorForm}. - - \snippet multipleinheritance/calculatorform.h 1 - - Two slots are defined according to the \l{Automatic Connections} - {automatic connection} naming convention required by \c uic. This is - to ensure that \l{QMetaObject}'s auto-connection facilities connect - all the signals and slots involved automatically. - - \section1 CalculatorForm Implementation - - In the constructor, we call \c setupUi() to load the user interface file. - Note that setupUi is a method of \c Ui::CalculatorForm. - - \snippet multipleinheritance/calculatorform.cpp 0 - - We include two slots, \c{on_inputSpinBox1_valueChanged()} and - \c{on_inputSpinBox2_valueChanged()}. These slots respond to the - \l{QSpinBox::valueChanged()}{valueChanged()} signal that both spin boxes - emit. Whenever there is a change in one spin box's value, we take that - value and add it to whatever value the other spin box has. - - \snippet multipleinheritance/calculatorform.cpp 1 - \codeline - \snippet multipleinheritance/calculatorform.cpp 2 - - \section1 \c main() Function - - The \c main() function instantiates QApplication and \c CalculatorForm. - The \c calculator object is displayed by invoking the \l{QWidget::show()} - {show()} function. - - \snippet multipleinheritance/main.cpp 0 - - There are various approaches to include forms into applications. The - Multiple Inheritance approach is just one of them. See - \l{Using a Designer UI File in Your Application} for more information on - the other approaches available. -*/ diff --git a/examples/uitools/multipleinheritance/CMakeLists.txt b/examples/uitools/multipleinheritance/CMakeLists.txt deleted file mode 100644 index 1081b7371..000000000 --- a/examples/uitools/multipleinheritance/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(multipleinheritance LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/uitools/multipleinheritance") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) - -qt_add_executable(multipleinheritance - calculatorform.cpp calculatorform.h calculatorform.ui - main.cpp -) - -set_target_properties(multipleinheritance PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(multipleinheritance PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS multipleinheritance - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/uitools/multipleinheritance/calculatorform.cpp b/examples/uitools/multipleinheritance/calculatorform.cpp deleted file mode 100644 index 6a877de7e..000000000 --- a/examples/uitools/multipleinheritance/calculatorform.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "calculatorform.h" -#include <QWidget> - - -//! [0] -CalculatorForm::CalculatorForm(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); -} -//! [0] - -//! [1] -void CalculatorForm::on_inputSpinBox1_valueChanged(int value) -{ - outputWidget->setText(QString::number(value + inputSpinBox2->value())); -} -//! [1] - -//! [2] -void CalculatorForm::on_inputSpinBox2_valueChanged(int value) -{ - outputWidget->setText(QString::number(value + inputSpinBox1->value())); -} -//! [2] diff --git a/examples/uitools/multipleinheritance/calculatorform.h b/examples/uitools/multipleinheritance/calculatorform.h deleted file mode 100644 index aba28c2ce..000000000 --- a/examples/uitools/multipleinheritance/calculatorform.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef CALCULATORFORM_H -#define CALCULATORFORM_H - -//! [0] -#include "ui_calculatorform.h" -//! [0] - -//! [1] -class CalculatorForm : public QWidget, private Ui::CalculatorForm -{ - Q_OBJECT - -public: - explicit CalculatorForm(QWidget *parent = nullptr); - -private slots: - void on_inputSpinBox1_valueChanged(int value); - void on_inputSpinBox2_valueChanged(int value); -}; -//! [1] - -#endif diff --git a/examples/uitools/multipleinheritance/calculatorform.ui b/examples/uitools/multipleinheritance/calculatorform.ui deleted file mode 100644 index dda0e62dd..000000000 --- a/examples/uitools/multipleinheritance/calculatorform.ui +++ /dev/null @@ -1,303 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>CalculatorForm</class> - <widget class="QWidget" name="CalculatorForm" > - <property name="objectName" > - <string notr="true" >CalculatorForm</string> - </property> - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>276</width> - <height>98</height> - </rect> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="windowTitle" > - <string>Calculator Builder</string> - </property> - <layout class="QGridLayout" > - <property name="objectName" > - <string notr="true" /> - </property> - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" /> - </property> - <property name="margin" > - <number>1</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" /> - </property> - <property name="margin" > - <number>1</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label" > - <property name="objectName" > - <string notr="true" >label</string> - </property> - <property name="geometry" > - <rect> - <x>1</x> - <y>1</y> - <width>45</width> - <height>19</height> - </rect> - </property> - <property name="text" > - <string>Input 1</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="inputSpinBox1" > - <property name="objectName" > - <string notr="true" >inputSpinBox1</string> - </property> - <property name="geometry" > - <rect> - <x>1</x> - <y>26</y> - <width>45</width> - <height>25</height> - </rect> - </property> - <property name="mouseTracking" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="label_3" > - <property name="objectName" > - <string notr="true" >label_3</string> - </property> - <property name="geometry" > - <rect> - <x>54</x> - <y>1</y> - <width>7</width> - <height>52</height> - </rect> - </property> - <property name="text" > - <string>+</string> - </property> - <property name="alignment" > - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" /> - </property> - <property name="margin" > - <number>1</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_2" > - <property name="objectName" > - <string notr="true" >label_2</string> - </property> - <property name="geometry" > - <rect> - <x>1</x> - <y>1</y> - <width>45</width> - <height>19</height> - </rect> - </property> - <property name="text" > - <string>Input 2</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="inputSpinBox2" > - <property name="objectName" > - <string notr="true" >inputSpinBox2</string> - </property> - <property name="geometry" > - <rect> - <x>1</x> - <y>26</y> - <width>45</width> - <height>25</height> - </rect> - </property> - <property name="mouseTracking" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="label_3_2" > - <property name="objectName" > - <string notr="true" >label_3_2</string> - </property> - <property name="geometry" > - <rect> - <x>120</x> - <y>1</y> - <width>7</width> - <height>52</height> - </rect> - </property> - <property name="text" > - <string>=</string> - </property> - <property name="alignment" > - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" /> - </property> - <property name="margin" > - <number>1</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_2_2_2" > - <property name="objectName" > - <string notr="true" >label_2_2_2</string> - </property> - <property name="geometry" > - <rect> - <x>1</x> - <y>1</y> - <width>37</width> - <height>17</height> - </rect> - </property> - <property name="text" > - <string>Output</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="outputWidget" > - <property name="objectName" > - <string notr="true" >outputWidget</string> - </property> - <property name="geometry" > - <rect> - <x>1</x> - <y>24</y> - <width>37</width> - <height>27</height> - </rect> - </property> - <property name="frameShape" > - <enum>QFrame::Box</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Sunken</enum> - </property> - <property name="text" > - <string>0</string> - </property> - <property name="alignment" > - <set>Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item row="1" column="0" > - <spacer> - <property name="objectName" > - <string notr="true" >verticalSpacer</string> - </property> - <property name="geometry" > - <rect> - <x>85</x> - <y>69</y> - <width>20</width> - <height>20</height> - </rect> - </property> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="1" > - <spacer> - <property name="objectName" > - <string notr="true" >horizontalSpacer</string> - </property> - <property name="geometry" > - <rect> - <x>188</x> - <y>26</y> - <width>79</width> - <height>20</height> - </rect> - </property> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <pixmapfunction></pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/examples/uitools/multipleinheritance/main.cpp b/examples/uitools/multipleinheritance/main.cpp deleted file mode 100644 index d6b0aee09..000000000 --- a/examples/uitools/multipleinheritance/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "calculatorform.h" -#include <QApplication> - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - CalculatorForm calculator; - calculator.show(); - return app.exec(); -} -//! [0] diff --git a/examples/uitools/multipleinheritance/multipleinheritance.pro b/examples/uitools/multipleinheritance/multipleinheritance.pro deleted file mode 100644 index fd40982ed..000000000 --- a/examples/uitools/multipleinheritance/multipleinheritance.pro +++ /dev/null @@ -1,11 +0,0 @@ -#! [0] -QT += widgets - -HEADERS = calculatorform.h -SOURCES = calculatorform.cpp main.cpp -FORMS = calculatorform.ui -#! [0] - -target.path = $$[QT_INSTALL_EXAMPLES]/uitools/multipleinheritance -INSTALLS += target - diff --git a/examples/uitools/uitools.pro b/examples/uitools/uitools.pro index bc2285d80..e0d22065e 100644 --- a/examples/uitools/uitools.pro +++ b/examples/uitools/uitools.pro @@ -1,4 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = multipleinheritance - -SUBDIRS += textfinder +SUBDIRS = textfinder |