diff options
Diffstat (limited to 'examples/uitools')
18 files changed, 47 insertions, 865 deletions
diff --git a/examples/uitools/CMakeLists.txt b/examples/uitools/CMakeLists.txt index a31646da0..16d288cbc 100644 --- a/examples/uitools/CMakeLists.txt +++ b/examples/uitools/CMakeLists.txt @@ -1,4 +1 @@ -# Generated from uitools.pro. - -add_subdirectory(multipleinheritance) -add_subdirectory(textfinder) +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/images/textfinder-example-userinterface.png b/examples/uitools/doc/images/textfinder-example-userinterface.png Binary files differdeleted file mode 100644 index 2bebe2e9d..000000000 --- a/examples/uitools/doc/images/textfinder-example-userinterface.png +++ /dev/null diff --git a/examples/uitools/doc/images/textfinder-example-userinterface.webp b/examples/uitools/doc/images/textfinder-example-userinterface.webp Binary files differnew file mode 100644 index 000000000..e746c7304 --- /dev/null +++ b/examples/uitools/doc/images/textfinder-example-userinterface.webp diff --git a/examples/uitools/doc/src/multipleinheritance.qdoc b/examples/uitools/doc/src/multipleinheritance.qdoc deleted file mode 100644 index da39d4b90..000000000 --- a/examples/uitools/doc/src/multipleinheritance.qdoc +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://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$ -** -****************************************************************************/ - -/*! - \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/doc/src/textfinder.qdoc b/examples/uitools/doc/src/textfinder.qdoc index b6d1936ee..91cfac5db 100644 --- a/examples/uitools/doc/src/textfinder.qdoc +++ b/examples/uitools/doc/src/textfinder.qdoc @@ -1,34 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example textfinder + \examplecategory {Desktop} + \meta tags {widgets,designer} \ingroup examples-qtuitools - \title Text Finder Example + \title Text Finder \brief Dynamically loading .ui files using QUiLoader. @@ -41,8 +19,8 @@ loaded at runtime, from a the program resources. \table - \row \li \inlineimage textfinder-example-find.png - \li \inlineimage textfinder-example-find2.png + \row \li \inlineimage textfinder-example-find.webp + \li \inlineimage textfinder-example-find2.webp \endtable \section1 Setting Up The Resource File @@ -50,7 +28,7 @@ The resources required for the example are: \list \li \c{textfinder.ui} - the user interface file created in - \l{Qt Designer} + \l{Qt Widgets Designer} \li \c{input.txt} - a text file containing some text to be displayed in a QTextEdit \endlist @@ -62,9 +40,9 @@ that all the widgets have sensible \c{objectName}'s assigned. These are used in code to identify them. - The screenshot below shows the preview obtained in \l{Qt Designer}. + The screenshot below shows the preview obtained in \l{Qt Widgets Designer}. - \image textfinder-example-userinterface.png + \image doc/images/textfinder-example-userinterface.webp In this example, we store both resources in the applicaton's executable by including the \c{textfinder.qrc} file. Alternatively, the files could also @@ -103,7 +81,7 @@ \c{loadUiFile} and \c{loadTextFile}. The \c{loadUiFile} function loads the user interface file previously - created in \l{Qt Designer}. First, the content of the \c{textfinder.ui} + created in \l{Qt Widgets Designer}. First, the content of the \c{textfinder.ui} file is loaded from the resource system. Then a QUiLoader instance is created, and the QUiLoader::load() function is called, with the first argument being the open file, and the second argument being the pointer of @@ -174,5 +152,5 @@ QUILoader is just one of them. See \l{Using a Designer UI File in Your Application} for more information on the other approaches available. - \sa {Calculator Builder Example}, {World Time Clock Builder Example} + \sa {Calculator Builder} */ diff --git a/examples/uitools/multipleinheritance/CMakeLists.txt b/examples/uitools/multipleinheritance/CMakeLists.txt deleted file mode 100644 index 59c240144..000000000 --- a/examples/uitools/multipleinheritance/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from multipleinheritance.pro. - -cmake_minimum_required(VERSION 3.16) -project(multipleinheritance 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}/uitools/multipleinheritance") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS 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 73bbd4fe5..000000000 --- a/examples/uitools/multipleinheritance/calculatorform.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "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 28a885c82..000000000 --- a/examples/uitools/multipleinheritance/calculatorform.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 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 4a6c600c8..000000000 --- a/examples/uitools/multipleinheritance/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 "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/textfinder/CMakeLists.txt b/examples/uitools/textfinder/CMakeLists.txt index 96911c675..21e4f08d5 100644 --- a/examples/uitools/textfinder/CMakeLists.txt +++ b/examples/uitools/textfinder/CMakeLists.txt @@ -1,40 +1,40 @@ -# Generated from textfinder.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(textfinder 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") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/uitools/textfinder") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS UiTools) +#! [0] +find_package(Qt6 REQUIRED COMPONENTS Core Gui UiTools Widgets) +#! [0] qt_add_executable(textfinder main.cpp textfinder.cpp textfinder.h ) + set_target_properties(textfinder PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) + +#! [1] target_link_libraries(textfinder PUBLIC Qt::Core Qt::Gui Qt::UiTools Qt::Widgets ) - +#! [1] # Resources: set(textfinder_resource_files diff --git a/examples/uitools/textfinder/forms/textfinder.ui b/examples/uitools/textfinder/forms/textfinder.ui index 9ea3011e8..f8cec91d1 100644 --- a/examples/uitools/textfinder/forms/textfinder.ui +++ b/examples/uitools/textfinder/forms/textfinder.ui @@ -47,7 +47,11 @@ <number>6</number> </property> <item row="0" column="1"> - <widget class="QLineEdit" name="lineEdit"/> + <widget class="QLineEdit" name="lineEdit"> + <property name="clearButtonEnabled"> + <bool>true</bool> + </property> + </widget> </item> <item row="0" column="0"> <widget class="QLabel" name="searchLabel"> diff --git a/examples/uitools/textfinder/main.cpp b/examples/uitools/textfinder/main.cpp index 3db26ebe7..c1e2e690c 100644 --- a/examples/uitools/textfinder/main.cpp +++ b/examples/uitools/textfinder/main.cpp @@ -1,54 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "textfinder.h" + #include <QApplication> //! [0] diff --git a/examples/uitools/textfinder/textfinder.cpp b/examples/uitools/textfinder/textfinder.cpp index d6c11906b..b8a59f7dc 100644 --- a/examples/uitools/textfinder/textfinder.cpp +++ b/examples/uitools/textfinder/textfinder.cpp @@ -1,67 +1,25 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "textfinder.h" -#include <QFile> + +#include <QUiLoader> + #include <QLineEdit> #include <QMessageBox> #include <QPushButton> #include <QTextEdit> -#include <QTextStream> -#include <QUiLoader> #include <QVBoxLayout> +#include <QFile> +#include <QTextStream> + +using namespace Qt::StringLiterals; + //! [4] static QWidget *loadUiFile(QWidget *parent) { - QFile file(":/forms/textfinder.ui"); + QFile file(u":/forms/textfinder.ui"_s); file.open(QIODevice::ReadOnly); QUiLoader loader; @@ -72,7 +30,7 @@ static QWidget *loadUiFile(QWidget *parent) //! [5] static QString loadTextFile() { - QFile inputFile(":/forms/input.txt"); + QFile inputFile(u":/forms/input.txt"_s); inputFile.open(QIODevice::ReadOnly); QTextStream in(&inputFile); return in.readAll(); @@ -100,9 +58,8 @@ TextFinder::TextFinder(QWidget *parent) //! [3a] //! [3b] - QVBoxLayout *layout = new QVBoxLayout; + auto *layout = new QVBoxLayout(this); layout->addWidget(formWidget); - setLayout(layout); //! [3b] //! [3c] diff --git a/examples/uitools/textfinder/textfinder.h b/examples/uitools/textfinder/textfinder.h index 17336d260..a9204c166 100644 --- a/examples/uitools/textfinder/textfinder.h +++ b/examples/uitools/textfinder/textfinder.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef TEXTFINDER_H #define TEXTFINDER_H 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 |