diff options
Diffstat (limited to 'examples/widgets')
1072 files changed, 4688 insertions, 49596 deletions
diff --git a/examples/widgets/.prev_CMakeLists.txt b/examples/widgets/.prev_CMakeLists.txt deleted file mode 100644 index cffc0a6293..0000000000 --- a/examples/widgets/.prev_CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Generated from widgets.pro. - -if(NOT TARGET Qt::Widgets) - return() -endif() -if(QT_FEATURE_animation) - add_subdirectory(animation) -endif() -add_subdirectory(desktop) -add_subdirectory(dialogs) -add_subdirectory(effects) -add_subdirectory(gallery) -add_subdirectory(gestures) -add_subdirectory(graphicsview) -add_subdirectory(itemviews) -add_subdirectory(layouts) -add_subdirectory(painting) -add_subdirectory(richtext) -add_subdirectory(scroller) -add_subdirectory(tools) -add_subdirectory(touch) -add_subdirectory(tutorials) -add_subdirectory(widgets) -if(QT_FEATURE_draganddrop) - add_subdirectory(draganddrop) -endif() -if(QT_FEATURE_cursor) - add_subdirectory(mainwindows) -endif() -if(QT_FEATURE_opengl AND TARGET Qt::Gui) - add_subdirectory(windowcontainer) -endif() diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt index 753e3b8499..315865b841 100644 --- a/examples/widgets/CMakeLists.txt +++ b/examples/widgets/CMakeLists.txt @@ -1,6 +1,7 @@ -# Generated from widgets.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -if(NOT TARGET Qt::Widgets) +if(NOT TARGET Qt6::Widgets) return() endif() if(QT_FEATURE_animation) @@ -24,9 +25,9 @@ add_subdirectory(widgets) if(QT_FEATURE_draganddrop) add_subdirectory(draganddrop) endif() -if(QT_FEATURE_cursor) # special case +if(QT_FEATURE_cursor) add_subdirectory(mainwindows) endif() -if(QT_FEATURE_opengl AND TARGET Qt::Gui) +if(QT_FEATURE_opengl AND TARGET Qt6::Gui) qt_internal_add_example(windowcontainer) endif() diff --git a/examples/widgets/animation/CMakeLists.txt b/examples/widgets/animation/CMakeLists.txt index 70f484a778..d9a18bb866 100644 --- a/examples/widgets/animation/CMakeLists.txt +++ b/examples/widgets/animation/CMakeLists.txt @@ -1,3 +1 @@ -# Generated from animation.pro. - qt_internal_add_example(easing) diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt index 4a577c5c0c..7c42f910b4 100644 --- a/examples/widgets/animation/easing/CMakeLists.txt +++ b/examples/widgets/animation/easing/CMakeLists.txt @@ -1,23 +1,18 @@ -# Generated from easing.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(easing 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}/widgets/animation/easing") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(easing animation.h @@ -25,23 +20,24 @@ qt_add_executable(easing main.cpp window.cpp window.h ) + set_target_properties(easing PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(easing PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) +target_link_libraries(easing PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) # Resources: set(easing_resource_files "images/qt-logo.png" ) -qt6_add_resources(easing "easing" +qt_add_resources(easing "easing" PREFIX "/" FILES diff --git a/examples/widgets/animation/easing/animation.h b/examples/widgets/animation/easing/animation.h index 696257bb4a..111ad44f45 100644 --- a/examples/widgets/animation/easing/animation.h +++ b/examples/widgets/animation/easing/animation.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef ANIMATION_H #define ANIMATION_H @@ -62,8 +15,8 @@ public: CirclePath, NPathTypes }; - Animation(QObject *target, const QByteArray &prop) - : QPropertyAnimation(target, prop) + Animation(QObject *target, const QByteArray &prop, QObject *parent = nullptr) + : QPropertyAnimation(target, prop, parent) { setPathType(LinearPath); } diff --git a/examples/widgets/animation/easing/main.cpp b/examples/widgets/animation/easing/main.cpp index df2f11f8cf..26009a6bf7 100644 --- a/examples/widgets/animation/easing/main.cpp +++ b/examples/widgets/animation/easing/main.cpp @@ -1,59 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtWidgets> #include "window.h" int main(int argc, char **argv) { - Q_INIT_RESOURCE(easing); QApplication app(argc, argv); Window w; diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp index 7b4fe1d912..d926efc537 100644 --- a/examples/widgets/animation/easing/window.cpp +++ b/examples/widgets/animation/easing/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" @@ -82,14 +35,14 @@ Window::Window(QWidget *parent) m_scene.addItem(m_item); m_ui.graphicsView->setScene(&m_scene); - m_anim = new Animation(m_item, "pos"); + m_anim = new Animation(m_item, "pos", this); m_anim->setEasingCurve(QEasingCurve::OutBounce); m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce)); startAnimation(); } -QEasingCurve createEasingCurve(QEasingCurve::Type curveType) +static QEasingCurve createEasingCurve(QEasingCurve::Type curveType) { QEasingCurve curve(curveType); @@ -119,12 +72,12 @@ void Window::createCurveIcons() // Skip QEasingCurve::Custom for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); - QEasingCurve curve = createEasingCurve((QEasingCurve::Type) i); + QEasingCurve curve = createEasingCurve(static_cast<QEasingCurve::Type>(i)); painter.setPen(QColor(0, 0, 255, 64)); qreal xAxis = m_iconSize.height()/1.5; qreal yAxis = m_iconSize.width()/3; - painter.drawLine(0, xAxis, m_iconSize.width(), xAxis); - painter.drawLine(yAxis, 0, yAxis, m_iconSize.height()); + painter.drawLine(QLineF(0, xAxis, m_iconSize.width(), xAxis)); + painter.drawLine(QLineF(yAxis, 0, yAxis, m_iconSize.height())); qreal curveScale = m_iconSize.height()/2; @@ -132,18 +85,18 @@ void Window::createCurveIcons() // start point painter.setBrush(Qt::red); - QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0)); + QPoint start(qRound(yAxis), qRound(xAxis - curveScale * curve.valueForProgress(0))); painter.drawRect(start.x() - 1, start.y() - 1, 3, 3); // end point painter.setBrush(Qt::blue); - QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1)); + QPoint end(qRound(yAxis + curveScale), qRound(xAxis - curveScale * curve.valueForProgress(1))); painter.drawRect(end.x() - 1, end.y() - 1, 3, 3); QPainterPath curvePath; curvePath.moveTo(start); for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) { - QPoint to; + QPointF to; to.setX(yAxis + curveScale * t); to.setY(xAxis - curveScale * curve.valueForProgress(t)); curvePath.lineTo(to); @@ -169,7 +122,7 @@ void Window::startAnimation() void Window::curveChanged(int row) { - QEasingCurve::Type curveType = (QEasingCurve::Type)row; + QEasingCurve::Type curveType = static_cast<QEasingCurve::Type>(row); m_anim->setEasingCurve(createEasingCurve(curveType)); m_anim->setCurrentTime(0); diff --git a/examples/widgets/animation/easing/window.h b/examples/widgets/animation/easing/window.h index 0c49dd6e8a..ea6bb74667 100644 --- a/examples/widgets/animation/easing/window.h +++ b/examples/widgets/animation/easing/window.h @@ -1,52 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef WINDOW_H +#define WINDOW_H #include <QtWidgets> @@ -84,3 +40,5 @@ private: Animation *m_anim; QSize m_iconSize; }; + +#endif // WINDOW_H diff --git a/examples/widgets/desktop/CMakeLists.txt b/examples/widgets/desktop/CMakeLists.txt index b317205c43..169fa9ffac 100644 --- a/examples/widgets/desktop/CMakeLists.txt +++ b/examples/widgets/desktop/CMakeLists.txt @@ -1,4 +1,2 @@ -# Generated from desktop.pro. - qt_internal_add_example(screenshot) qt_internal_add_example(systray) diff --git a/examples/widgets/desktop/screenshot/CMakeLists.txt b/examples/widgets/desktop/screenshot/CMakeLists.txt index bbc525c719..cba4215afa 100644 --- a/examples/widgets/desktop/screenshot/CMakeLists.txt +++ b/examples/widgets/desktop/screenshot/CMakeLists.txt @@ -1,36 +1,33 @@ -# Generated from screenshot.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(screenshot 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}/widgets/desktop/screenshot") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(screenshot main.cpp screenshot.cpp screenshot.h ) + set_target_properties(screenshot PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(screenshot PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(screenshot PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS screenshot diff --git a/examples/widgets/desktop/screenshot/main.cpp b/examples/widgets/desktop/screenshot/main.cpp index 96b0d57daa..64bde12e95 100644 --- a/examples/widgets/desktop/screenshot/main.cpp +++ b/examples/widgets/desktop/screenshot/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> #include <QScreen> diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp index 522b1123b5..5a4ba901b7 100644 --- a/examples/widgets/desktop/screenshot/screenshot.cpp +++ b/examples/widgets/desktop/screenshot/screenshot.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtWidgets> @@ -109,7 +62,7 @@ void Screenshot::resizeEvent(QResizeEvent * /* event */) { QSize scaledSize = originalPixmap.size(); scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio); - if (scaledSize != screenshotLabel->pixmap(Qt::ReturnByValue).size()) + if (scaledSize != screenshotLabel->pixmap().size()) updateScreenshotLabel(); } //! [1] diff --git a/examples/widgets/desktop/screenshot/screenshot.h b/examples/widgets/desktop/screenshot/screenshot.h index 240952120d..c7e10858ee 100644 --- a/examples/widgets/desktop/screenshot/screenshot.h +++ b/examples/widgets/desktop/screenshot/screenshot.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef SCREENSHOT_H #define SCREENSHOT_H diff --git a/examples/widgets/desktop/systray/CMakeLists.txt b/examples/widgets/desktop/systray/CMakeLists.txt index f52a523ad4..4aaed39edf 100644 --- a/examples/widgets/desktop/systray/CMakeLists.txt +++ b/examples/widgets/desktop/systray/CMakeLists.txt @@ -1,38 +1,34 @@ -# Generated from systray.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(systray 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}/widgets/desktop/systray") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(systray main.cpp window.cpp window.h ) + set_target_properties(systray PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(systray PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) +target_link_libraries(systray PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) # Resources: set(systray_resource_files @@ -41,7 +37,7 @@ set(systray_resource_files "images/trash.png" ) -qt6_add_resources(systray "systray" +qt_add_resources(systray "systray" PREFIX "/" FILES diff --git a/examples/widgets/desktop/systray/doc/src/systray.qdoc b/examples/widgets/desktop/systray/doc/src/systray.qdoc index ae7e925bd8..5c4350383d 100644 --- a/examples/widgets/desktop/systray/doc/src/systray.qdoc +++ b/examples/widgets/desktop/systray/doc/src/systray.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example desktop/systray @@ -173,11 +149,11 @@ We have reimplemented the QWidget::closeEvent() event handler to receive widget close events, showing the above message to the - users when they are closing the editor window. On \macos we need to + users when they are closing the editor window. We need to avoid showing the message and accepting the close event when the - user really intends to quit the application, that is, when the - user has triggered "Quit" in the menu bar or pressed the Command+Q - shortcut. + user really intends to quit the application: that is, when the + user has triggered "Quit" in the menu bar, or in the tray icon's + context menu, or pressed Command+Q shortcut on \macOS. In addition to the functions and slots discussed above, we have also implemented several convenience functions to simplify the diff --git a/examples/widgets/desktop/systray/main.cpp b/examples/widgets/desktop/systray/main.cpp index 4e3e628767..d13bde11ce 100644 --- a/examples/widgets/desktop/systray/main.cpp +++ b/examples/widgets/desktop/systray/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> @@ -57,8 +10,6 @@ int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(systray); - QApplication app(argc, argv); if (!QSystemTrayIcon::isSystemTrayAvailable()) { diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp index e62b5fc0d0..c5632759b0 100644 --- a/examples/widgets/desktop/systray/window.cpp +++ b/examples/widgets/desktop/systray/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" @@ -111,11 +64,8 @@ void Window::setVisible(bool visible) //! [2] void Window::closeEvent(QCloseEvent *event) { -#ifdef Q_OS_MACOS - if (!event->spontaneous() || !isVisible()) { + if (!event->spontaneous() || !isVisible()) return; - } -#endif if (trayIcon->isVisible()) { QMessageBox::information(this, tr("Systray"), tr("The program will keep running in the " diff --git a/examples/widgets/desktop/systray/window.h b/examples/widgets/desktop/systray/window.h index 001338df0c..69978b1ba2 100644 --- a/examples/widgets/desktop/systray/window.h +++ b/examples/widgets/desktop/systray/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H diff --git a/examples/widgets/dialogs/.prev_CMakeLists.txt b/examples/widgets/dialogs/.prev_CMakeLists.txt deleted file mode 100644 index 354424bf1f..0000000000 --- a/examples/widgets/dialogs/.prev_CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from dialogs.pro. - -if(QT_FEATURE_wizard) - add_subdirectory(classwizard) - add_subdirectory(trivialwizard) -endif() -add_subdirectory(extension) -add_subdirectory(findfiles) -add_subdirectory(standarddialogs) -add_subdirectory(tabdialog) -if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport) - add_subdirectory(licensewizard) -endif() diff --git a/examples/widgets/dialogs/CMakeLists.txt b/examples/widgets/dialogs/CMakeLists.txt index 32f8bc29a8..b16cbc7f44 100644 --- a/examples/widgets/dialogs/CMakeLists.txt +++ b/examples/widgets/dialogs/CMakeLists.txt @@ -1,13 +1,11 @@ -# Generated from dialogs.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause if(QT_FEATURE_wizard) - qt_internal_add_example(classwizard) qt_internal_add_example(trivialwizard) + if(Qt6::PrintSupport) + qt_internal_add_example(licensewizard) + endif() endif() -qt_internal_add_example(extension) -qt_internal_add_example(findfiles) qt_internal_add_example(standarddialogs) qt_internal_add_example(tabdialog) -if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport) - qt_internal_add_example(licensewizard) -endif() diff --git a/examples/widgets/dialogs/classwizard/CMakeLists.txt b/examples/widgets/dialogs/classwizard/CMakeLists.txt deleted file mode 100644 index b45c5bbc15..0000000000 --- a/examples/widgets/dialogs/classwizard/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Generated from classwizard.pro. - -cmake_minimum_required(VERSION 3.16) -project(classwizard LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/classwizard") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(classwizard - classwizard.cpp classwizard.h - main.cpp -) -set_target_properties(classwizard PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(classwizard PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(classwizard_resource_files - "images/background.png" - "images/banner.png" - "images/logo1.png" - "images/logo2.png" - "images/logo3.png" - "images/watermark1.png" - "images/watermark2.png" -) - -qt6_add_resources(classwizard "classwizard" - PREFIX - "/" - FILES - ${classwizard_resource_files} -) - -install(TARGETS classwizard - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/dialogs/classwizard/classwizard.cpp b/examples/widgets/dialogs/classwizard/classwizard.cpp deleted file mode 100644 index 8421289eab..0000000000 --- a/examples/widgets/dialogs/classwizard/classwizard.cpp +++ /dev/null @@ -1,441 +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 <QtWidgets> - -#include "classwizard.h" - -//! [0] //! [1] -ClassWizard::ClassWizard(QWidget *parent) - : QWizard(parent) -{ - addPage(new IntroPage); - addPage(new ClassInfoPage); - addPage(new CodeStylePage); - addPage(new OutputFilesPage); - addPage(new ConclusionPage); -//! [0] - - setPixmap(QWizard::BannerPixmap, QPixmap(":/images/banner.png")); - setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/background.png")); - - setWindowTitle(tr("Class Wizard")); -//! [2] -} -//! [1] //! [2] - -//! [3] -void ClassWizard::accept() -//! [3] //! [4] -{ - QByteArray className = field("className").toByteArray(); - QByteArray baseClass = field("baseClass").toByteArray(); - QByteArray macroName = field("macroName").toByteArray(); - QByteArray baseInclude = field("baseInclude").toByteArray(); - - QString outputDir = field("outputDir").toString(); - QString header = field("header").toString(); - QString implementation = field("implementation").toString(); -//! [4] - - QByteArray block; - - if (field("comment").toBool()) { - block += "/*\n"; - block += " " + header.toLatin1() + '\n'; - block += "*/\n"; - block += '\n'; - } - if (field("protect").toBool()) { - block += "#ifndef " + macroName + '\n'; - block += "#define " + macroName + '\n'; - block += '\n'; - } - if (field("includeBase").toBool()) { - block += "#include " + baseInclude + '\n'; - block += '\n'; - } - - block += "class " + className; - if (!baseClass.isEmpty()) - block += " : public " + baseClass; - block += '\n'; - block += "{\n"; - - /* qmake ignore Q_OBJECT */ - - if (field("qobjectMacro").toBool()) { - block += " Q_OBJECT\n"; - block += '\n'; - } - block += "public:\n"; - - if (field("qobjectCtor").toBool()) { - block += " " + className + "(QObject *parent = nullptr);\n"; - } else if (field("qwidgetCtor").toBool()) { - block += " " + className + "(QWidget *parent = nullptr);\n"; - } else if (field("defaultCtor").toBool()) { - block += " " + className + "();\n"; - if (field("copyCtor").toBool()) { - block += " " + className + "(const " + className + " &other);\n"; - block += '\n'; - block += " " + className + " &operator=" + "(const " + className - + " &other);\n"; - } - } - block += "};\n"; - - if (field("protect").toBool()) { - block += '\n'; - block += "#endif\n"; - } - - QFile headerFile(outputDir + '/' + header); - if (!headerFile.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(nullptr, QObject::tr("Simple Wizard"), - QObject::tr("Cannot write file %1:\n%2") - .arg(headerFile.fileName()) - .arg(headerFile.errorString())); - return; - } - headerFile.write(block); - - block.clear(); - - if (field("comment").toBool()) { - block += "/*\n"; - block += " " + implementation.toLatin1() + '\n'; - block += "*/\n"; - block += '\n'; - } - block += "#include \"" + header.toLatin1() + "\"\n"; - block += '\n'; - - if (field("qobjectCtor").toBool()) { - block += className + "::" + className + "(QObject *parent)\n"; - block += " : " + baseClass + "(parent)\n"; - block += "{\n"; - block += "}\n"; - } else if (field("qwidgetCtor").toBool()) { - block += className + "::" + className + "(QWidget *parent)\n"; - block += " : " + baseClass + "(parent)\n"; - block += "{\n"; - block += "}\n"; - } else if (field("defaultCtor").toBool()) { - block += className + "::" + className + "()\n"; - block += "{\n"; - block += " // missing code\n"; - block += "}\n"; - - if (field("copyCtor").toBool()) { - block += "\n"; - block += className + "::" + className + "(const " + className - + " &other)\n"; - block += "{\n"; - block += " *this = other;\n"; - block += "}\n"; - block += '\n'; - block += className + " &" + className + "::operator=(const " - + className + " &other)\n"; - block += "{\n"; - if (!baseClass.isEmpty()) - block += " " + baseClass + "::operator=(other);\n"; - block += " // missing code\n"; - block += " return *this;\n"; - block += "}\n"; - } - } - - QFile implementationFile(outputDir + '/' + implementation); - if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(nullptr, QObject::tr("Simple Wizard"), - QObject::tr("Cannot write file %1:\n%2") - .arg(implementationFile.fileName()) - .arg(implementationFile.errorString())); - return; - } - implementationFile.write(block); - -//! [5] - QDialog::accept(); -//! [5] //! [6] -} -//! [6] - -//! [7] -IntroPage::IntroPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Introduction")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark1.png")); - - label = new QLabel(tr("This wizard will generate a skeleton C++ class " - "definition, including a few functions. You simply " - "need to specify the class name and set a few " - "options to produce a header file and an " - "implementation file for your new C++ class.")); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - setLayout(layout); -} -//! [7] - -//! [8] //! [9] -ClassInfoPage::ClassInfoPage(QWidget *parent) - : QWizardPage(parent) -{ -//! [8] - setTitle(tr("Class Information")); - setSubTitle(tr("Specify basic information about the class for which you " - "want to generate skeleton source code files.")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo1.png")); - -//! [10] - classNameLabel = new QLabel(tr("&Class name:")); - classNameLineEdit = new QLineEdit; - classNameLabel->setBuddy(classNameLineEdit); - - baseClassLabel = new QLabel(tr("B&ase class:")); - baseClassLineEdit = new QLineEdit; - baseClassLabel->setBuddy(baseClassLineEdit); - - qobjectMacroCheckBox = new QCheckBox(tr("Generate Q_OBJECT ¯o")); - -//! [10] - groupBox = new QGroupBox(tr("C&onstructor")); -//! [9] - - qobjectCtorRadioButton = new QRadioButton(tr("&QObject-style constructor")); - qwidgetCtorRadioButton = new QRadioButton(tr("Q&Widget-style constructor")); - defaultCtorRadioButton = new QRadioButton(tr("&Default constructor")); - copyCtorCheckBox = new QCheckBox(tr("&Generate copy constructor and " - "operator=")); - - defaultCtorRadioButton->setChecked(true); - - connect(defaultCtorRadioButton, &QAbstractButton::toggled, - copyCtorCheckBox, &QWidget::setEnabled); - -//! [11] //! [12] - registerField("className*", classNameLineEdit); - registerField("baseClass", baseClassLineEdit); - registerField("qobjectMacro", qobjectMacroCheckBox); -//! [11] - registerField("qobjectCtor", qobjectCtorRadioButton); - registerField("qwidgetCtor", qwidgetCtorRadioButton); - registerField("defaultCtor", defaultCtorRadioButton); - registerField("copyCtor", copyCtorCheckBox); - - QVBoxLayout *groupBoxLayout = new QVBoxLayout; -//! [12] - groupBoxLayout->addWidget(qobjectCtorRadioButton); - groupBoxLayout->addWidget(qwidgetCtorRadioButton); - groupBoxLayout->addWidget(defaultCtorRadioButton); - groupBoxLayout->addWidget(copyCtorCheckBox); - groupBox->setLayout(groupBoxLayout); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(classNameLabel, 0, 0); - layout->addWidget(classNameLineEdit, 0, 1); - layout->addWidget(baseClassLabel, 1, 0); - layout->addWidget(baseClassLineEdit, 1, 1); - layout->addWidget(qobjectMacroCheckBox, 2, 0, 1, 2); - layout->addWidget(groupBox, 3, 0, 1, 2); - setLayout(layout); -//! [13] -} -//! [13] - -//! [14] -CodeStylePage::CodeStylePage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Code Style Options")); - setSubTitle(tr("Choose the formatting of the generated code.")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo2.png")); - - commentCheckBox = new QCheckBox(tr("&Start generated files with a " -//! [14] - "comment")); - commentCheckBox->setChecked(true); - - protectCheckBox = new QCheckBox(tr("&Protect header file against multiple " - "inclusions")); - protectCheckBox->setChecked(true); - - macroNameLabel = new QLabel(tr("&Macro name:")); - macroNameLineEdit = new QLineEdit; - macroNameLabel->setBuddy(macroNameLineEdit); - - includeBaseCheckBox = new QCheckBox(tr("&Include base class definition")); - baseIncludeLabel = new QLabel(tr("Base class include:")); - baseIncludeLineEdit = new QLineEdit; - baseIncludeLabel->setBuddy(baseIncludeLineEdit); - - connect(protectCheckBox, &QAbstractButton::toggled, - macroNameLabel, &QWidget::setEnabled); - connect(protectCheckBox, &QAbstractButton::toggled, - macroNameLineEdit, &QWidget::setEnabled); - connect(includeBaseCheckBox, &QAbstractButton::toggled, - baseIncludeLabel, &QWidget::setEnabled); - connect(includeBaseCheckBox, &QAbstractButton::toggled, - baseIncludeLineEdit, &QWidget::setEnabled); - - registerField("comment", commentCheckBox); - registerField("protect", protectCheckBox); - registerField("macroName", macroNameLineEdit); - registerField("includeBase", includeBaseCheckBox); - registerField("baseInclude", baseIncludeLineEdit); - - QGridLayout *layout = new QGridLayout; - layout->setColumnMinimumWidth(0, 20); - layout->addWidget(commentCheckBox, 0, 0, 1, 3); - layout->addWidget(protectCheckBox, 1, 0, 1, 3); - layout->addWidget(macroNameLabel, 2, 1); - layout->addWidget(macroNameLineEdit, 2, 2); - layout->addWidget(includeBaseCheckBox, 3, 0, 1, 3); - layout->addWidget(baseIncludeLabel, 4, 1); - layout->addWidget(baseIncludeLineEdit, 4, 2); -//! [15] - setLayout(layout); -} -//! [15] - -//! [16] -void CodeStylePage::initializePage() -{ - QString className = field("className").toString(); - macroNameLineEdit->setText(className.toUpper() + "_H"); - - QString baseClass = field("baseClass").toString(); - - includeBaseCheckBox->setChecked(!baseClass.isEmpty()); - includeBaseCheckBox->setEnabled(!baseClass.isEmpty()); - baseIncludeLabel->setEnabled(!baseClass.isEmpty()); - baseIncludeLineEdit->setEnabled(!baseClass.isEmpty()); - - QRegularExpression rx("Q[A-Z].*"); - if (baseClass.isEmpty()) { - baseIncludeLineEdit->clear(); - } else if (rx.match(baseClass).hasMatch()) { - baseIncludeLineEdit->setText('<' + baseClass + '>'); - } else { - baseIncludeLineEdit->setText('"' + baseClass.toLower() + ".h\""); - } -} -//! [16] - -OutputFilesPage::OutputFilesPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Output Files")); - setSubTitle(tr("Specify where you want the wizard to put the generated " - "skeleton code.")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo3.png")); - - outputDirLabel = new QLabel(tr("&Output directory:")); - outputDirLineEdit = new QLineEdit; - outputDirLabel->setBuddy(outputDirLineEdit); - - headerLabel = new QLabel(tr("&Header file name:")); - headerLineEdit = new QLineEdit; - headerLabel->setBuddy(headerLineEdit); - - implementationLabel = new QLabel(tr("&Implementation file name:")); - implementationLineEdit = new QLineEdit; - implementationLabel->setBuddy(implementationLineEdit); - - registerField("outputDir*", outputDirLineEdit); - registerField("header*", headerLineEdit); - registerField("implementation*", implementationLineEdit); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(outputDirLabel, 0, 0); - layout->addWidget(outputDirLineEdit, 0, 1); - layout->addWidget(headerLabel, 1, 0); - layout->addWidget(headerLineEdit, 1, 1); - layout->addWidget(implementationLabel, 2, 0); - layout->addWidget(implementationLineEdit, 2, 1); - setLayout(layout); -} - -//! [17] -void OutputFilesPage::initializePage() -{ - QString className = field("className").toString(); - headerLineEdit->setText(className.toLower() + ".h"); - implementationLineEdit->setText(className.toLower() + ".cpp"); - outputDirLineEdit->setText(QDir::toNativeSeparators(QDir::tempPath())); -} -//! [17] - -ConclusionPage::ConclusionPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Conclusion")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark2.png")); - - label = new QLabel; - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - setLayout(layout); -} - -void ConclusionPage::initializePage() -{ - QString finishText = wizard()->buttonText(QWizard::FinishButton); - finishText.remove('&'); - label->setText(tr("Click %1 to generate the class skeleton.") - .arg(finishText)); -} diff --git a/examples/widgets/dialogs/classwizard/classwizard.h b/examples/widgets/dialogs/classwizard/classwizard.h deleted file mode 100644 index 0c386f0553..0000000000 --- a/examples/widgets/dialogs/classwizard/classwizard.h +++ /dev/null @@ -1,166 +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$ -** -****************************************************************************/ - -#ifndef CLASSWIZARD_H -#define CLASSWIZARD_H - -#include <QWizard> - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QRadioButton; -QT_END_NAMESPACE - -//! [0] -class ClassWizard : public QWizard -{ - Q_OBJECT - -public: - ClassWizard(QWidget *parent = nullptr); - - void accept() override; -}; -//! [0] - -//! [1] -class IntroPage : public QWizardPage -{ - Q_OBJECT - -public: - IntroPage(QWidget *parent = nullptr); - -private: - QLabel *label; -}; -//! [1] - -//! [2] -class ClassInfoPage : public QWizardPage -{ - Q_OBJECT - -public: - ClassInfoPage(QWidget *parent = nullptr); - -private: - QLabel *classNameLabel; - QLabel *baseClassLabel; - QLineEdit *classNameLineEdit; - QLineEdit *baseClassLineEdit; - QCheckBox *qobjectMacroCheckBox; - QGroupBox *groupBox; - QRadioButton *qobjectCtorRadioButton; - QRadioButton *qwidgetCtorRadioButton; - QRadioButton *defaultCtorRadioButton; - QCheckBox *copyCtorCheckBox; -}; -//! [2] - -//! [3] -class CodeStylePage : public QWizardPage -{ - Q_OBJECT - -public: - CodeStylePage(QWidget *parent = nullptr); - -protected: - void initializePage() override; - -private: - QCheckBox *commentCheckBox; - QCheckBox *protectCheckBox; - QCheckBox *includeBaseCheckBox; - QLabel *macroNameLabel; - QLabel *baseIncludeLabel; - QLineEdit *macroNameLineEdit; - QLineEdit *baseIncludeLineEdit; -}; -//! [3] - -class OutputFilesPage : public QWizardPage -{ - Q_OBJECT - -public: - OutputFilesPage(QWidget *parent = nullptr); - -protected: - void initializePage() override; - -private: - QLabel *outputDirLabel; - QLabel *headerLabel; - QLabel *implementationLabel; - QLineEdit *outputDirLineEdit; - QLineEdit *headerLineEdit; - QLineEdit *implementationLineEdit; -}; - -class ConclusionPage : public QWizardPage -{ - Q_OBJECT - -public: - ConclusionPage(QWidget *parent = nullptr); - -protected: - void initializePage() override; - -private: - QLabel *label; -}; - -#endif diff --git a/examples/widgets/dialogs/classwizard/classwizard.pro b/examples/widgets/dialogs/classwizard/classwizard.pro deleted file mode 100644 index 3ec321f4e8..0000000000 --- a/examples/widgets/dialogs/classwizard/classwizard.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT += widgets - -HEADERS = classwizard.h -SOURCES = classwizard.cpp \ - main.cpp -RESOURCES = classwizard.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/classwizard -INSTALLS += target diff --git a/examples/widgets/dialogs/classwizard/classwizard.qrc b/examples/widgets/dialogs/classwizard/classwizard.qrc deleted file mode 100644 index 41a5ddc7d1..0000000000 --- a/examples/widgets/dialogs/classwizard/classwizard.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/background.png</file> - <file>images/banner.png</file> - <file>images/logo1.png</file> - <file>images/logo2.png</file> - <file>images/logo3.png</file> - <file>images/watermark1.png</file> - <file>images/watermark2.png</file> -</qresource> -</RCC> diff --git a/examples/widgets/dialogs/classwizard/images/background.png b/examples/widgets/dialogs/classwizard/images/background.png Binary files differdeleted file mode 100644 index 44c7badb85..0000000000 --- a/examples/widgets/dialogs/classwizard/images/background.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/images/banner.png b/examples/widgets/dialogs/classwizard/images/banner.png Binary files differdeleted file mode 100644 index 3169152b8e..0000000000 --- a/examples/widgets/dialogs/classwizard/images/banner.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/images/logo1.png b/examples/widgets/dialogs/classwizard/images/logo1.png Binary files differdeleted file mode 100644 index f9b594aafc..0000000000 --- a/examples/widgets/dialogs/classwizard/images/logo1.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/images/logo2.png b/examples/widgets/dialogs/classwizard/images/logo2.png Binary files differdeleted file mode 100644 index 5dcbd4669d..0000000000 --- a/examples/widgets/dialogs/classwizard/images/logo2.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/images/logo3.png b/examples/widgets/dialogs/classwizard/images/logo3.png Binary files differdeleted file mode 100644 index 9fd3ea2358..0000000000 --- a/examples/widgets/dialogs/classwizard/images/logo3.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/images/watermark1.png b/examples/widgets/dialogs/classwizard/images/watermark1.png Binary files differdeleted file mode 100644 index 0091f5c17a..0000000000 --- a/examples/widgets/dialogs/classwizard/images/watermark1.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/images/watermark2.png b/examples/widgets/dialogs/classwizard/images/watermark2.png Binary files differdeleted file mode 100644 index 3b88f2e360..0000000000 --- a/examples/widgets/dialogs/classwizard/images/watermark2.png +++ /dev/null diff --git a/examples/widgets/dialogs/classwizard/main.cpp b/examples/widgets/dialogs/classwizard/main.cpp deleted file mode 100644 index 612d194c06..0000000000 --- a/examples/widgets/dialogs/classwizard/main.cpp +++ /dev/null @@ -1,75 +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 <QApplication> -#include <QTranslator> -#include <QLocale> -#include <QLibraryInfo> - -#include "classwizard.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(classwizard); - - QApplication app(argc, argv); - -#ifndef QT_NO_TRANSLATION - QString translatorFileName = QLatin1String("qtbase_"); - translatorFileName += QLocale::system().name(); - QTranslator *translator = new QTranslator(&app); - if (translator->load(translatorFileName, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) - app.installTranslator(translator); -#endif - - ClassWizard wizard; - wizard.show(); - return app.exec(); -} diff --git a/examples/widgets/dialogs/dialogs.pro b/examples/widgets/dialogs/dialogs.pro index 753308fc55..2493688297 100644 --- a/examples/widgets/dialogs/dialogs.pro +++ b/examples/widgets/dialogs/dialogs.pro @@ -1,10 +1,7 @@ QT_FOR_CONFIG += widgets TEMPLATE = subdirs -SUBDIRS = classwizard \ - extension \ - findfiles \ - licensewizard \ +SUBDIRS = licensewizard \ standarddialogs \ tabdialog \ trivialwizard diff --git a/examples/widgets/dialogs/extension/CMakeLists.txt b/examples/widgets/dialogs/extension/CMakeLists.txt deleted file mode 100644 index be555e6a10..0000000000 --- a/examples/widgets/dialogs/extension/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from extension.pro. - -cmake_minimum_required(VERSION 3.16) -project(extension LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/extension") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(extension - finddialog.cpp finddialog.h - main.cpp -) -set_target_properties(extension PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(extension PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS extension - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/dialogs/extension/extension.pro b/examples/widgets/dialogs/extension/extension.pro deleted file mode 100644 index f51052cd56..0000000000 --- a/examples/widgets/dialogs/extension/extension.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += widgets - -HEADERS = finddialog.h -SOURCES = finddialog.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/extension -INSTALLS += target diff --git a/examples/widgets/dialogs/extension/finddialog.cpp b/examples/widgets/dialogs/extension/finddialog.cpp deleted file mode 100644 index 10a4ae1ac0..0000000000 --- a/examples/widgets/dialogs/extension/finddialog.cpp +++ /dev/null @@ -1,124 +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 <QtWidgets> - -#include "finddialog.h" - -//! [0] -FindDialog::FindDialog(QWidget *parent) - : QDialog(parent) -{ - label = new QLabel(tr("Find &what:")); - lineEdit = new QLineEdit; - label->setBuddy(lineEdit); - - caseCheckBox = new QCheckBox(tr("Match &case")); - fromStartCheckBox = new QCheckBox(tr("Search from &start")); - fromStartCheckBox->setChecked(true); - -//! [1] - findButton = new QPushButton(tr("&Find")); - findButton->setDefault(true); - - moreButton = new QPushButton(tr("&More")); - moreButton->setCheckable(true); -//! [0] - moreButton->setAutoDefault(false); - -//! [1] - -//! [2] - extension = new QWidget; - - wholeWordsCheckBox = new QCheckBox(tr("&Whole words")); - backwardCheckBox = new QCheckBox(tr("Search &backward")); - searchSelectionCheckBox = new QCheckBox(tr("Search se&lection")); -//! [2] - -//! [3] - buttonBox = new QDialogButtonBox(Qt::Vertical); - buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); - - connect(moreButton, &QAbstractButton::toggled, extension, &QWidget::setVisible); - - QVBoxLayout *extensionLayout = new QVBoxLayout; - extensionLayout->setContentsMargins(QMargins()); - extensionLayout->addWidget(wholeWordsCheckBox); - extensionLayout->addWidget(backwardCheckBox); - extensionLayout->addWidget(searchSelectionCheckBox); - extension->setLayout(extensionLayout); -//! [3] - -//! [4] - QHBoxLayout *topLeftLayout = new QHBoxLayout; - topLeftLayout->addWidget(label); - topLeftLayout->addWidget(lineEdit); - - QVBoxLayout *leftLayout = new QVBoxLayout; - leftLayout->addLayout(topLeftLayout); - leftLayout->addWidget(caseCheckBox); - leftLayout->addWidget(fromStartCheckBox); - - QGridLayout *mainLayout = new QGridLayout; - mainLayout->setSizeConstraint(QLayout::SetFixedSize); - mainLayout->addLayout(leftLayout, 0, 0); - mainLayout->addWidget(buttonBox, 0, 1); - mainLayout->addWidget(extension, 1, 0, 1, 2); - mainLayout->setRowStretch(2, 1); - - setLayout(mainLayout); - - setWindowTitle(tr("Extension")); -//! [4] //! [5] - extension->hide(); -} -//! [5] diff --git a/examples/widgets/dialogs/extension/finddialog.h b/examples/widgets/dialogs/extension/finddialog.h deleted file mode 100644 index 9b4b5b5f3d..0000000000 --- a/examples/widgets/dialogs/extension/finddialog.h +++ /dev/null @@ -1,88 +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$ -** -****************************************************************************/ - -#ifndef FINDDIALOG_H -#define FINDDIALOG_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QDialogButtonBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -QT_END_NAMESPACE - -//! [0] -class FindDialog : public QDialog -{ - Q_OBJECT - -public: - FindDialog(QWidget *parent = nullptr); - -private: - QLabel *label; - QLineEdit *lineEdit; - QCheckBox *caseCheckBox; - QCheckBox *fromStartCheckBox; - QCheckBox *wholeWordsCheckBox; - QCheckBox *searchSelectionCheckBox; - QCheckBox *backwardCheckBox; - QDialogButtonBox *buttonBox; - QPushButton *findButton; - QPushButton *moreButton; - QWidget *extension; -}; -//! [0] - -#endif diff --git a/examples/widgets/dialogs/extension/main.cpp b/examples/widgets/dialogs/extension/main.cpp deleted file mode 100644 index 7fa2883fe1..0000000000 --- a/examples/widgets/dialogs/extension/main.cpp +++ /dev/null @@ -1,63 +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 <QApplication> - -#include "finddialog.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - FindDialog dialog; - - dialog.show(); - - return app.exec(); -} diff --git a/examples/widgets/dialogs/findfiles/CMakeLists.txt b/examples/widgets/dialogs/findfiles/CMakeLists.txt deleted file mode 100644 index cf183d29e2..0000000000 --- a/examples/widgets/dialogs/findfiles/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from findfiles.pro. - -cmake_minimum_required(VERSION 3.16) -project(findfiles LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/findfiles") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(findfiles - main.cpp - window.cpp window.h -) -set_target_properties(findfiles PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(findfiles PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS findfiles - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/dialogs/findfiles/findfiles.pro b/examples/widgets/dialogs/findfiles/findfiles.pro deleted file mode 100644 index 4fb77f0dd7..0000000000 --- a/examples/widgets/dialogs/findfiles/findfiles.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT += widgets -requires(qtConfig(filedialog)) - -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/findfiles -INSTALLS += target diff --git a/examples/widgets/dialogs/findfiles/main.cpp b/examples/widgets/dialogs/findfiles/main.cpp deleted file mode 100644 index 99725195e5..0000000000 --- a/examples/widgets/dialogs/findfiles/main.cpp +++ /dev/null @@ -1,61 +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 <QApplication> - -#include "window.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/dialogs/findfiles/window.cpp b/examples/widgets/dialogs/findfiles/window.cpp deleted file mode 100644 index e1f7ccdcc4..0000000000 --- a/examples/widgets/dialogs/findfiles/window.cpp +++ /dev/null @@ -1,311 +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 <QtWidgets> - -#include "window.h" - -//! [17] -enum { absoluteFileNameRole = Qt::UserRole + 1 }; -//! [17] - -//! [18] -static inline QString fileNameOfItem(const QTableWidgetItem *item) -{ - return item->data(absoluteFileNameRole).toString(); -} -//! [18] - -//! [14] -static inline void openFile(const QString &fileName) -{ - QDesktopServices::openUrl(QUrl::fromLocalFile(fileName)); -} -//! [14] - -//! [0] -Window::Window(QWidget *parent) - : QWidget(parent) -{ - setWindowTitle(tr("Find Files")); - QPushButton *browseButton = new QPushButton(tr("&Browse..."), this); - connect(browseButton, &QAbstractButton::clicked, this, &Window::browse); - findButton = new QPushButton(tr("&Find"), this); - connect(findButton, &QAbstractButton::clicked, this, &Window::find); - - fileComboBox = createComboBox(tr("*")); - connect(fileComboBox->lineEdit(), &QLineEdit::returnPressed, - this, &Window::animateFindClick); - textComboBox = createComboBox(); - connect(textComboBox->lineEdit(), &QLineEdit::returnPressed, - this, &Window::animateFindClick); - directoryComboBox = createComboBox(QDir::toNativeSeparators(QDir::currentPath())); - connect(directoryComboBox->lineEdit(), &QLineEdit::returnPressed, - this, &Window::animateFindClick); - - filesFoundLabel = new QLabel; - - createFilesTable(); - - QGridLayout *mainLayout = new QGridLayout(this); - mainLayout->addWidget(new QLabel(tr("Named:")), 0, 0); - mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); - mainLayout->addWidget(new QLabel(tr("Containing text:")), 1, 0); - mainLayout->addWidget(textComboBox, 1, 1, 1, 2); - mainLayout->addWidget(new QLabel(tr("In directory:")), 2, 0); - mainLayout->addWidget(directoryComboBox, 2, 1); - mainLayout->addWidget(browseButton, 2, 2); - mainLayout->addWidget(filesTable, 3, 0, 1, 3); - mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2); - mainLayout->addWidget(findButton, 4, 2); -//! [0] - -//! [1] - connect(new QShortcut(QKeySequence::Quit, this), &QShortcut::activated, - qApp, &QApplication::quit); -//! [1] -} - -//! [2] -void Window::browse() -{ - QString directory = - QDir::toNativeSeparators(QFileDialog::getExistingDirectory(this, tr("Find Files"), QDir::currentPath())); - - if (!directory.isEmpty()) { - if (directoryComboBox->findText(directory) == -1) - directoryComboBox->addItem(directory); - directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory)); - } -} -//! [2] - -static void updateComboBox(QComboBox *comboBox) -{ - if (comboBox->findText(comboBox->currentText()) == -1) - comboBox->addItem(comboBox->currentText()); -} - -//! [3] -void Window::find() -{ - filesTable->setRowCount(0); - - QString fileName = fileComboBox->currentText(); - QString text = textComboBox->currentText(); - QString path = QDir::cleanPath(directoryComboBox->currentText()); - currentDir = QDir(path); -//! [3] - - updateComboBox(fileComboBox); - updateComboBox(textComboBox); - updateComboBox(directoryComboBox); - -//! [4] - QStringList filter; - if (!fileName.isEmpty()) - filter << fileName; - QDirIterator it(path, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); - QStringList files; - while (it.hasNext()) - files << it.next(); - if (!text.isEmpty()) - files = findFiles(files, text); - files.sort(); - showFiles(files); -} -//! [4] - -void Window::animateFindClick() -{ - findButton->animateClick(); -} - -//! [5] -QStringList Window::findFiles(const QStringList &files, const QString &text) -{ - QProgressDialog progressDialog(this); - progressDialog.setCancelButtonText(tr("&Cancel")); - progressDialog.setRange(0, files.size()); - progressDialog.setWindowTitle(tr("Find Files")); - -//! [5] //! [6] - QMimeDatabase mimeDatabase; - QStringList foundFiles; - - for (int i = 0; i < files.size(); ++i) { - progressDialog.setValue(i); - progressDialog.setLabelText(tr("Searching file number %1 of %n...", nullptr, files.size()).arg(i)); - QCoreApplication::processEvents(); -//! [6] - - if (progressDialog.wasCanceled()) - break; - -//! [7] - const QString fileName = files.at(i); - const QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileName); - if (mimeType.isValid() && !mimeType.inherits(QStringLiteral("text/plain"))) { - qWarning() << "Not searching binary file " << QDir::toNativeSeparators(fileName); - continue; - } - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - QString line; - QTextStream in(&file); - while (!in.atEnd()) { - if (progressDialog.wasCanceled()) - break; - line = in.readLine(); - if (line.contains(text, Qt::CaseInsensitive)) { - foundFiles << files[i]; - break; - } - } - } - } - return foundFiles; -} -//! [7] - -//! [8] -void Window::showFiles(const QStringList &paths) -{ - for (const QString &filePath : paths) { - const QString toolTip = QDir::toNativeSeparators(filePath); - const QString relativePath = QDir::toNativeSeparators(currentDir.relativeFilePath(filePath)); - const qint64 size = QFileInfo(filePath).size(); - QTableWidgetItem *fileNameItem = new QTableWidgetItem(relativePath); - fileNameItem->setData(absoluteFileNameRole, QVariant(filePath)); - fileNameItem->setToolTip(toolTip); - fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable); - QTableWidgetItem *sizeItem = new QTableWidgetItem(QLocale().formattedDataSize(size)); - sizeItem->setData(absoluteFileNameRole, QVariant(filePath)); - sizeItem->setToolTip(toolTip); - sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); - sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable); - - int row = filesTable->rowCount(); - filesTable->insertRow(row); - filesTable->setItem(row, 0, fileNameItem); - filesTable->setItem(row, 1, sizeItem); - } - filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", nullptr, paths.size())); - filesFoundLabel->setWordWrap(true); -} -//! [8] - -//! [10] -QComboBox *Window::createComboBox(const QString &text) -{ - QComboBox *comboBox = new QComboBox; - comboBox->setEditable(true); - comboBox->addItem(text); - comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - return comboBox; -} -//! [10] - -//! [11] -void Window::createFilesTable() -{ - filesTable = new QTableWidget(0, 2); - filesTable->setSelectionBehavior(QAbstractItemView::SelectRows); - - QStringList labels; - labels << tr("Filename") << tr("Size"); - filesTable->setHorizontalHeaderLabels(labels); - filesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); - filesTable->verticalHeader()->hide(); - filesTable->setShowGrid(false); -//! [15] - filesTable->setContextMenuPolicy(Qt::CustomContextMenu); - connect(filesTable, &QTableWidget::customContextMenuRequested, - this, &Window::contextMenu); - connect(filesTable, &QTableWidget::cellActivated, - this, &Window::openFileOfItem); -//! [15] -} -//! [11] - - -//! [12] - -void Window::openFileOfItem(int row, int /* column */) -{ - const QTableWidgetItem *item = filesTable->item(row, 0); - openFile(fileNameOfItem(item)); -} - -//! [12] - -//! [16] -void Window::contextMenu(const QPoint &pos) -{ - const QTableWidgetItem *item = filesTable->itemAt(pos); - if (!item) - return; - QMenu menu; -#ifndef QT_NO_CLIPBOARD - QAction *copyAction = menu.addAction("Copy Name"); -#endif - QAction *openAction = menu.addAction("Open"); - QAction *action = menu.exec(filesTable->mapToGlobal(pos)); - if (!action) - return; - const QString fileName = fileNameOfItem(item); - if (action == openAction) - openFile(fileName); -#ifndef QT_NO_CLIPBOARD - else if (action == copyAction) - QGuiApplication::clipboard()->setText(QDir::toNativeSeparators(fileName)); -#endif -} -//! [16] diff --git a/examples/widgets/dialogs/findfiles/window.h b/examples/widgets/dialogs/findfiles/window.h deleted file mode 100644 index b74ba5e70c..0000000000 --- a/examples/widgets/dialogs/findfiles/window.h +++ /dev/null @@ -1,97 +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$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include <QWidget> -#include <QDir> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QLabel; -class QPushButton; -class QTableWidget; -class QTableWidgetItem; -QT_END_NAMESPACE - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(QWidget *parent = nullptr); - -private slots: - void browse(); - void find(); - void animateFindClick(); - void openFileOfItem(int row, int column); - void contextMenu(const QPoint &pos); - -private: - QStringList findFiles(const QStringList &files, const QString &text); - void showFiles(const QStringList &paths); - QComboBox *createComboBox(const QString &text = QString()); - void createFilesTable(); - - QComboBox *fileComboBox; - QComboBox *textComboBox; - QComboBox *directoryComboBox; - QLabel *filesFoundLabel; - QPushButton *findButton; - QTableWidget *filesTable; - - QDir currentDir; -}; -//! [0] - -#endif diff --git a/examples/widgets/dialogs/licensewizard/CMakeLists.txt b/examples/widgets/dialogs/licensewizard/CMakeLists.txt index 7fc7ac65fa..a6cda7a74a 100644 --- a/examples/widgets/dialogs/licensewizard/CMakeLists.txt +++ b/examples/widgets/dialogs/licensewizard/CMakeLists.txt @@ -1,40 +1,35 @@ -# Generated from licensewizard.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(licensewizard 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}/widgets/dialogs/licensewizard") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS PrintSupport) +find_package(Qt6 REQUIRED COMPONENTS Core Gui PrintSupport Widgets) + +qt_standard_project_setup() qt_add_executable(licensewizard licensewizard.cpp licensewizard.h main.cpp ) + set_target_properties(licensewizard PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(licensewizard PUBLIC - Qt::Core - Qt::Gui - Qt::PrintSupport - Qt::Widgets -) +target_link_libraries(licensewizard PRIVATE + Qt6::Core + Qt6::Gui + Qt6::PrintSupport + Qt6::Widgets +) # Resources: set(licensewizard_resource_files @@ -42,7 +37,7 @@ set(licensewizard_resource_files "images/watermark.png" ) -qt6_add_resources(licensewizard "licensewizard" +qt_add_resources(licensewizard "licensewizard" PREFIX "/" FILES diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp index 2eaadd1cba..67fa46bf07 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp +++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtWidgets> #if defined(QT_PRINTSUPPORT_LIB) @@ -335,9 +288,12 @@ void ConclusionPage::initializePage() "You can use this software for 30 days and make one " "backup, but you are not allowed to distribute it."); } else if (wizard()->hasVisitedPage(LicenseWizard::Page_Details)) { +//! [accessField] + const QString emailAddress = field("details.email").toString(); licenseText = tr("<u>First-Time License Agreement:</u> " "You can use this software subject to the license " - "you will receive by email."); + "you will receive by email sent to %1.").arg(emailAddress); +//! [accessField] } else { licenseText = tr("<u>Upgrade License Agreement:</u> " "This software is licensed under the terms of your " diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.h b/examples/widgets/dialogs/licensewizard/licensewizard.h index e2890e484f..c163a2af9d 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.h +++ b/examples/widgets/dialogs/licensewizard/licensewizard.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef LICENSEWIZARD_H #define LICENSEWIZARD_H diff --git a/examples/widgets/dialogs/licensewizard/main.cpp b/examples/widgets/dialogs/licensewizard/main.cpp index 47fdb4a09d..d16b5dc6d1 100644 --- a/examples/widgets/dialogs/licensewizard/main.cpp +++ b/examples/widgets/dialogs/licensewizard/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> #include <QTranslator> @@ -57,8 +10,6 @@ int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(licensewizard); - QApplication app(argc, argv); #ifndef QT_NO_TRANSLATION diff --git a/examples/widgets/dialogs/standarddialogs/CMakeLists.txt b/examples/widgets/dialogs/standarddialogs/CMakeLists.txt index 9cb52e22dd..3116603c98 100644 --- a/examples/widgets/dialogs/standarddialogs/CMakeLists.txt +++ b/examples/widgets/dialogs/standarddialogs/CMakeLists.txt @@ -1,36 +1,33 @@ -# Generated from standarddialogs.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(standarddialogs 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}/widgets/dialogs/standarddialogs") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(standarddialogs dialog.cpp dialog.h main.cpp ) + set_target_properties(standarddialogs PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(standarddialogs PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(standarddialogs PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS standarddialogs diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp index 7df24e06f6..af8df344c7 100644 --- a/examples/widgets/dialogs/standarddialogs/dialog.cpp +++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp @@ -1,67 +1,10 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtWidgets> #include "dialog.h" -#define MESSAGE \ - Dialog::tr("<p>Message boxes have a caption, a text, " \ - "and any number of buttons, each with standard or custom texts." \ - "<p>Click a button to close the message box. Pressing the Esc button " \ - "will activate the detected escape button (if any).") -#define MESSAGE_DETAILS \ - Dialog::tr("If a message box has detailed text, the user can reveal it " \ - "by pressing the Show Details... button.") - - class DialogOptionsWidget : public QGroupBox { public: @@ -99,7 +42,7 @@ void DialogOptionsWidget::addSpacer() int DialogOptionsWidget::value() const { int result = 0; - for (const CheckBoxEntry &checkboxEntry : qAsConst(checkBoxEntries)) { + for (const CheckBoxEntry &checkboxEntry : std::as_const(checkBoxEntries)) { if (checkboxEntry.first->isChecked()) result |= checkboxEntry.second; } @@ -195,8 +138,6 @@ Dialog::Dialog(QWidget *parent) warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); - errorLabel = new QLabel; - errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QErrorMessage::showM&essage()")); @@ -306,7 +247,6 @@ Dialog::Dialog(QWidget *parent) layout->addWidget(warningButton, 3, 0); layout->addWidget(warningLabel, 3, 1); layout->addWidget(errorButton, 4, 0); - layout->addWidget(errorLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Message Boxes")); @@ -460,10 +400,14 @@ void Dialog::setSaveFileName() void Dialog::criticalMessage() { - QMessageBox::StandardButton reply; - reply = QMessageBox::critical(this, tr("QMessageBox::critical()"), - MESSAGE, - QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore); + QMessageBox msgBox(QMessageBox::Critical, tr("QMessageBox::critical()"), + tr("Houston, we have a problem"), { }, this); + msgBox.setInformativeText(tr("Activating the liquid oxygen stirring fans caused an explosion in one of the tanks. " \ + "Liquid oxygen levels are getting low. This may jeopardize the moon landing mission.")); + msgBox.addButton(QMessageBox::Abort); + msgBox.addButton(QMessageBox::Retry); + msgBox.addButton(QMessageBox::Ignore); + int reply = msgBox.exec(); if (reply == QMessageBox::Abort) criticalLabel->setText(tr("Abort")); else if (reply == QMessageBox::Retry) @@ -474,9 +418,12 @@ void Dialog::criticalMessage() void Dialog::informationMessage() { - QMessageBox::StandardButton reply; - reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE); - if (reply == QMessageBox::Ok) + QMessageBox msgBox(QMessageBox::Information, tr("QMessageBox::information()"), + tr("Elvis has left the building."), { }, this); + msgBox.setInformativeText(tr("This phrase was often used by public address announcers at the conclusion " \ + "of Elvis Presley concerts in order to disperse audiences who lingered in " \ + "hopes of an encore. It has since become a catchphrase and punchline.")); + if (msgBox.exec() == QMessageBox::Ok) informationLabel->setText(tr("OK")); else informationLabel->setText(tr("Escape")); @@ -484,10 +431,15 @@ void Dialog::informationMessage() void Dialog::questionMessage() { - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this, tr("QMessageBox::question()"), - MESSAGE, - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + QMessageBox msgBox(QMessageBox::Question, tr("QMessageBox::question()"), + tr("Would you like cheese with that?"), { }, this); + msgBox.setInformativeText(tr("A cheeseburger is a hamburger topped with cheese. Traditionally, the slice of " \ + "cheese is placed on top of the meat patty. The cheese is usually added to the " \ + "cooking hamburger patty shortly before serving, which allows the cheese to melt.")); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + msgBox.addButton(QMessageBox::Cancel); + int reply = msgBox.exec(); if (reply == QMessageBox::Yes) questionLabel->setText(tr("Yes")); else if (reply == QMessageBox::No) @@ -499,14 +451,15 @@ void Dialog::questionMessage() void Dialog::warningMessage() { QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"), - MESSAGE, { }, this); - msgBox.setDetailedText(MESSAGE_DETAILS); - msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole); - msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole); + tr("Delete the only copy of your movie manuscript?"), { }, this); + msgBox.setInformativeText(tr("You've been working on this manuscript for 738 days now. Hang in there!")); + msgBox.setDetailedText("\"A long time ago in a galaxy far, far away....\""); + msgBox.addButton(tr("&Keep"), QMessageBox::AcceptRole); + msgBox.addButton(tr("Delete"), QMessageBox::DestructiveRole); if (msgBox.exec() == QMessageBox::AcceptRole) - warningLabel->setText(tr("Save Again")); + warningLabel->setText(tr("Keep")); else - warningLabel->setText(tr("Continue")); + warningLabel->setText(tr("Delete")); } @@ -514,11 +467,13 @@ void Dialog::errorMessage() { errorMessageDialog->showMessage( tr("This dialog shows and remembers error messages. " - "If the checkbox is checked (as it is by default), " - "the shown message will be shown again, " - "but if the user unchecks the box the message " + "If the user chooses to not show the dialog again, the dialog " "will not appear again if QErrorMessage::showMessage() " "is called with the same message.")); - errorLabel->setText(tr("If the box is unchecked, the message " - "won't appear again.")); + errorMessageDialog->showMessage( + tr("You can queue up error messages, and they will be " + "shown one after each other. Each message maintains " + "its own state for whether it will be shown again " + "the next time QErrorMessage::showMessage() is called " + "with the same message.")); } diff --git a/examples/widgets/dialogs/standarddialogs/dialog.h b/examples/widgets/dialogs/standarddialogs/dialog.h index 6d9cbdc07a..88d0f7519f 100644 --- a/examples/widgets/dialogs/standarddialogs/dialog.h +++ b/examples/widgets/dialogs/standarddialogs/dialog.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef DIALOG_H #define DIALOG_H @@ -102,7 +55,6 @@ private: QLabel *informationLabel; QLabel *questionLabel; QLabel *warningLabel; - QLabel *errorLabel; QErrorMessage *errorMessageDialog; DialogOptionsWidget *fileDialogOptionsWidget; DialogOptionsWidget *colorDialogOptionsWidget; diff --git a/examples/widgets/dialogs/standarddialogs/main.cpp b/examples/widgets/dialogs/standarddialogs/main.cpp index 7e7a5ce95b..c982ef36c5 100644 --- a/examples/widgets/dialogs/standarddialogs/main.cpp +++ b/examples/widgets/dialogs/standarddialogs/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> #include <QScreen> @@ -57,13 +10,15 @@ #include "dialog.h" +using namespace Qt::StringLiterals; + int main(int argc, char *argv[]) { QApplication app(argc, argv); #if QT_CONFIG(translation) QTranslator translator; - if (translator.load(QLocale::system(), u"qtbase"_qs, u"_"_qs, + if (translator.load(QLocale::system(), u"qtbase"_s, u"_"_s, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { app.installTranslator(&translator); } diff --git a/examples/widgets/dialogs/standarddialogs/main.mm b/examples/widgets/dialogs/standarddialogs/main.mm new file mode 100644 index 0000000000..558ef4e680 --- /dev/null +++ b/examples/widgets/dialogs/standarddialogs/main.mm @@ -0,0 +1,47 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include <QApplication> +#include <QScreen> +#include <QStyleHints> +#include <QTranslator> +#include <QLocale> +#include <QLibraryInfo> + +#include "dialog.h" + +#include <AppKit/AppKit.h> + +using namespace Qt::StringLiterals; + +int main(int argc, char *argv[]) +{ + [NSApplication sharedApplication]; + NSApplicationLoad(); + NSApplicationLoad(); + [NSApp run]; + + QApplication app(argc, argv); + //app.setAttribute(Qt::AA_DontUseNativeDialogs); + +#if QT_CONFIG(translation) + QTranslator translator; + if (translator.load(QLocale::system(), u"qtbase"_s, u"_"_s, + QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { + app.installTranslator(&translator); + } +#endif + + QGuiApplication::setApplicationDisplayName(Dialog::tr("Standard Dialogs")); + + Dialog dialog; + if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) { + const QRect availableGeometry = dialog.screen()->availableGeometry(); + dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3); + dialog.move((availableGeometry.width() - dialog.width()) / 2, + (availableGeometry.height() - dialog.height()) / 2); + } + dialog.show(); + + return app.exec(); +} diff --git a/examples/widgets/dialogs/tabdialog/CMakeLists.txt b/examples/widgets/dialogs/tabdialog/CMakeLists.txt index b61a8ef89c..6dfc49b294 100644 --- a/examples/widgets/dialogs/tabdialog/CMakeLists.txt +++ b/examples/widgets/dialogs/tabdialog/CMakeLists.txt @@ -1,36 +1,33 @@ -# Generated from tabdialog.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(tabdialog 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}/widgets/dialogs/tabdialog") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(tabdialog main.cpp tabdialog.cpp tabdialog.h ) + set_target_properties(tabdialog PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(tabdialog PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(tabdialog PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS tabdialog diff --git a/examples/widgets/dialogs/tabdialog/main.cpp b/examples/widgets/dialogs/tabdialog/main.cpp index d5ed426320..aa05ad0205 100644 --- a/examples/widgets/dialogs/tabdialog/main.cpp +++ b/examples/widgets/dialogs/tabdialog/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/dialogs/tabdialog/tabdialog.cpp b/examples/widgets/dialogs/tabdialog/tabdialog.cpp index e64413d6bb..cb4fcea11d 100644 --- a/examples/widgets/dialogs/tabdialog/tabdialog.cpp +++ b/examples/widgets/dialogs/tabdialog/tabdialog.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtWidgets> diff --git a/examples/widgets/dialogs/tabdialog/tabdialog.h b/examples/widgets/dialogs/tabdialog/tabdialog.h index b7c6c5b8da..27f07747d6 100644 --- a/examples/widgets/dialogs/tabdialog/tabdialog.h +++ b/examples/widgets/dialogs/tabdialog/tabdialog.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef TABDIALOG_H #define TABDIALOG_H diff --git a/examples/widgets/dialogs/trivialwizard/CMakeLists.txt b/examples/widgets/dialogs/trivialwizard/CMakeLists.txt index d57cbd59c3..c8efc8b8c5 100644 --- a/examples/widgets/dialogs/trivialwizard/CMakeLists.txt +++ b/examples/widgets/dialogs/trivialwizard/CMakeLists.txt @@ -1,35 +1,32 @@ -# Generated from trivialwizard.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(trivialwizard 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}/widgets/dialogs/trivialwizard") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(trivialwizard trivialwizard.cpp ) + set_target_properties(trivialwizard PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(trivialwizard PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(trivialwizard PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS trivialwizard diff --git a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp index e214a4e54a..b9321338a4 100644 --- a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp +++ b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtWidgets> #include <QTranslator> @@ -133,10 +86,12 @@ int main(int argc, char *argv[]) app.installTranslator(translator); #endif +//! [linearAddPage] QWizard wizard; wizard.addPage(createIntroPage()); wizard.addPage(createRegistrationPage()); wizard.addPage(createConclusionPage()); +//! [linearAddPage] wizard.setWindowTitle("Trivial Wizard"); wizard.show(); diff --git a/examples/widgets/doc/dropsite.qdoc b/examples/widgets/doc/dropsite.qdoc index 720d001525..5ebf0ff3a4 100644 --- a/examples/widgets/doc/dropsite.qdoc +++ b/examples/widgets/doc/dropsite.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example draganddrop/dropsite @@ -49,8 +25,8 @@ \snippet draganddrop/dropsite/droparea.h DropArea header part1 - In addition, \c DropArea also contains a private instance of QLabel and - reimplementations of four \l{QWidget} event handlers: + In addition, \c DropArea contains reimplementations of four \l{QWidget} + event handlers: \list 1 \li \l{QWidget::dragEnterEvent()}{dragEnterEvent()} diff --git a/examples/widgets/doc/images/graphicsanchorlayout-example.png b/examples/widgets/doc/images/graphicsanchorlayout-example.png Binary files differdeleted file mode 100644 index 3f35fdb6b7..0000000000 --- a/examples/widgets/doc/images/graphicsanchorlayout-example.png +++ /dev/null diff --git a/examples/widgets/doc/images/mousebutton-buttontester.png b/examples/widgets/doc/images/mousebutton-buttontester.png Binary files differdeleted file mode 100644 index f8f71db59b..0000000000 --- a/examples/widgets/doc/images/mousebutton-buttontester.png +++ /dev/null diff --git a/examples/widgets/doc/images/notepad1.png b/examples/widgets/doc/images/notepad1.png Binary files differindex 40d13269b9..91863de5c3 100644 --- a/examples/widgets/doc/images/notepad1.png +++ b/examples/widgets/doc/images/notepad1.png diff --git a/examples/widgets/doc/images/notepad2.png b/examples/widgets/doc/images/notepad2.png Binary files differindex 9cec1f9a58..599a5c68f4 100644 --- a/examples/widgets/doc/images/notepad2.png +++ b/examples/widgets/doc/images/notepad2.png diff --git a/examples/widgets/doc/images/notepad3.png b/examples/widgets/doc/images/notepad3.png Binary files differindex 426861ab06..d4f55ba2a0 100644 --- a/examples/widgets/doc/images/notepad3.png +++ b/examples/widgets/doc/images/notepad3.png diff --git a/examples/widgets/doc/images/stylepluginexample.png b/examples/widgets/doc/images/stylepluginexample.png Binary files differindex 05d8c6b5cf..9ff69c512b 100644 --- a/examples/widgets/doc/images/stylepluginexample.png +++ b/examples/widgets/doc/images/stylepluginexample.png diff --git a/examples/widgets/doc/images/undodemo.png b/examples/widgets/doc/images/undodemo.png Binary files differdeleted file mode 100644 index 85c3622738..0000000000 --- a/examples/widgets/doc/images/undodemo.png +++ /dev/null diff --git a/examples/widgets/doc/images/weatheranchorlayout-example.png b/examples/widgets/doc/images/weatheranchorlayout-example.png Binary files differdeleted file mode 100644 index 59d3b55b7a..0000000000 --- a/examples/widgets/doc/images/weatheranchorlayout-example.png +++ /dev/null diff --git a/examples/widgets/doc/mousebuttons.qdoc b/examples/widgets/doc/mousebuttons.qdoc deleted file mode 100644 index c64d22eceb..0000000000 --- a/examples/widgets/doc/mousebuttons.qdoc +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com> -** 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 widgets/mousebuttons - \title Mouse Button Tester - - \brief The 'Mouse Button Tester' example demonstrates how to reimplement - mouse events within a custom class. You can also use this program to - verify that Qt is actually receiving mouse events from your mouse. - - Many 'gamer' mouse devices are configured with high-numbered "buttons" - sending text shortcuts for certain games. With such a mouse, no mouse - button events occur: The "mouse" sends keystrokes, and the - 'Mouse Button Tester' Window will not see the event. Receiving no event, - it will not repaint the Window with new text describing a button event. - - And so, in addition to it's use as Qt example code, the program may be - useful s a mouse device tester. Note that there is another example - mouse buttons example which provides the same function, written in QML. - - This program (the Widget-based example) consists of three classes, - in addition to the main() parent program: - - \list - \li \c A QPushButton, "Quit". - \li \c ButtonTester. This is derived from Qt's TextArea class, for - purpose of customizing/re-implementing the mouse and wheel event - member functions. - \li \c A simple QVBoxLayout layout. - \endlist - - First we will review the main program, with it's layout and "Quit" - QPushButton. Then we will take a look at the \c ButtonTester class. - - \section1 The Main Program - - Note that the QPushButton, "Quit", is defined directly within the main() - program, rather than another class. This is a correct way of defining a - "Quit" QPushButton: A "Quit" Button defined inside another - class would result in the destructor of that second class being - called twice. This "Quit" Button uses the traditional Signal/Slot - connection to invoke termination of the QApp, which will properly destroy - its child classes before terminating itself. - - The remainder of the main() program is concerned with defining the layout, - and applying a minimum size to the customized ButtonTester. - - \section1 ButtonTester Class Definition - - The \c ButtonTester class inherits from QTextEdit, and listens for - mouse events on all possible Qt::MouseButton values. It also listens for - wheel events from the mouse, and indicates the direction of wheel motion - ("up", down", "left", or "right"). It prints short debug messages into - the Window, and also on the console QDebug() stream, when mouse button - and wheel events occur. Our reimplementation of mousePressEvent(), - mouseReleaseEvent(), mouseDoubleClickEvent(), and wheelEvent() "drive" - the program; the other functions simply convert the Qt::MouseButton - values into text strings. - - You should call the ignore() function on any mouse event (or other event) - which your widget-based classes do not use and consume. This function - assures that Qt will propagate the event through each parent widget, - until it is used or propagated to the Window Manager. (Qt attempts to do - this automatically, but it is better programming practice to explicitly - invoke the function.) - - \image mousebutton-buttontester.png -*/ diff --git a/examples/widgets/doc/src/addressbook-tutorial.qdoc b/examples/widgets/doc/src/addressbook-tutorial.qdoc deleted file mode 100644 index 53acb82b1a..0000000000 --- a/examples/widgets/doc/src/addressbook-tutorial.qdoc +++ /dev/null @@ -1,972 +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$ -** -****************************************************************************/ - -/*! - \page tutorials-addressbook.html - - \title Address Book Tutorial - \ingroup examples-layout - \brief An introduction to GUI programming, showing how to put together a - simple yet fully-functioning application. - - This tutorial is an introduction to GUI programming with the Qt - cross-platform framework. - - \image addressbook-tutorial-screenshot.png - - \omit - It doesn't cover everything; the emphasis is on teaching the programming - philosophy of GUI programming, and Qt's features are introduced as needed. - Some commonly used features are never used in this tutorial. - \endomit - - In this tutorial, you will learn about some of the basic - components of Qt, including: - - \list - \li Widgets and layout managers - \li Container classes - \li Signals and slots - \li Input and output devices - \endlist - - Tutorial contents: - - \list 1 - \li \l{tutorials/addressbook/part1}{Designing the User Interface} - \li \l{tutorials/addressbook/part2}{Adding Addresses} - \li \l{tutorials/addressbook/part3}{Navigating between Entries} - \li \l{tutorials/addressbook/part4}{Editing and Removing Addresses} - \li \l{tutorials/addressbook/part5}{Adding a Find Function} - \li \l{tutorials/addressbook/part6}{Loading and Saving} - \li \l{tutorials/addressbook/part7}{Additional Features} - \endlist - - The tutorial source code is located in \c{tutorials/addressbook}. - - Although this little application does not look much like a - fully-fledged modern GUI application, it uses many of the basic - elements that are used in more complex applications. After you - have worked through this tutorial, we recommend reading the - \l{mainwindows/application}{Application} example, which presents a - small GUI application, with menus, toolbars, a status bar, and so - on. -*/ - -/*! - \example tutorials/addressbook/part1 - \title Part 1 - Designing the User Interface - \brief Describes how to code the user interface of the Address Book Example. - This first part covers the design of the basic graphical user - interface (GUI) for our address book application. - - The first step in creating a GUI program is to design the user - interface. Here the our goal is to set up the labels and input - fields to implement a basic address book. The figure below is a - screenshot of the expected output. - - \image addressbook-tutorial-part1-screenshot.png - - We require two QLabel objects, \c nameLabel and \c addressLabel, as well - as two input fields, a QLineEdit object, \c nameLine, and a QTextEdit - object, \c addressText, to enable the user to enter a contact's name and - address. The widgets used and their positions are shown in the figure - below. - - \image addressbook-tutorial-part1-labeled-screenshot.png - - There are three files used to implement this address book: - - \list - \li \c{addressbook.h} - the definition file for the \c AddressBook - class, - \li \c{addressbook.cpp} - the implementation file for the - \c AddressBook class, and - \li \c{main.cpp} - the file containing a \c main() function, with - an instance of \c AddressBook. - \endlist - - \section1 Qt Programming - Subclassing - - When writing Qt programs, we usually subclass Qt objects to add - functionality. This is one of the essential concepts behind creating - custom widgets or collections of standard widgets. Subclassing to - extend or change the behavior of a widget has the following advantages: - - \list - \li We can write implementations of virtual or pure virtual functions to - obtain exactly what we need, falling back on the base class's implementation - when necessary. - \li It allows us to encapsulate parts of the user interface within a class, - so that the other parts of the application don't need to know about the - individual widgets in the user interface. - \li The subclass can be used to create multiple custom widgets in the same - application or library, and the code for the subclass can be reused in other - projects. - \endlist - - Since Qt does not provide a specific address book widget, we subclass a - standard Qt widget class and add features to it. The \c AddressBook class - we create in this tutorial can be reused in situations where a basic address - book widget is needed. - - \section1 Defining the AddressBook Class - - The \c{tutorials/addressbook/part1/addressbook.h} file is - used to define the \c AddressBook class. - - We start by defining \c AddressBook as a QWidget subclass and declaring - a constructor. We also use the Q_OBJECT macro to indicate that the class - uses internationalization and Qt's signals and slots features, even - if we do not use all of these features at this stage. - - \snippet tutorials/addressbook/part1/addressbook.h class definition - - The class holds declarations of \c nameLine and \c addressText, - the private instances of QLineEdit and QTextEdit mentioned - earlier. The data stored in \c nameLine and \c addressText will - be needed for many of the address book functions. - - We don't include declarations of the QLabel objects we will use - because we will not need to reference them once they have been - created. The way Qt tracks the ownership of objects is explained - in the next section. - - The Q_OBJECT macro itself implements some of the more advanced features of Qt. - For now, it is useful to think of the Q_OBJECT macro as a shortcut which allows - us to use the \l{QObject::}{tr()} and \l{QObject::}{connect()} functions. - - We have now completed the \c addressbook.h file and we move on to - implement the corresponding \c addressbook.cpp file. - - \section1 Implementing the AddressBook Class - - The constructor of \c AddressBook accepts a QWidget parameter, \a parent. - By convention, we pass this parameter to the base class's constructor. - This concept of ownership, where a parent can have one or more children, - is useful for grouping widgets in Qt. For example, if you delete a parent, - all of its children will be deleted as well. - - \snippet tutorials/addressbook/part1/addressbook.cpp constructor and input fields - - In this constructor, the QLabel objects \c nameLabel and \c - addressLabel are instantiated, as well as \c nameLine and \c - addressText. The \l{QObject::tr()}{tr()} function returns a - translated version of the string, if there is one - available. Otherwise it returns the string itself. This function - marks its QString parameter as one that should be translated into - other languages. It should be used wherever a translatable string - appears. - - When programming with Qt, it is useful to know how layouts work. - Qt provides three main layout classes: QHBoxLayout, QVBoxLayout - and QGridLayout to handle the positioning of widgets. - - \image addressbook-tutorial-part1-labeled-layout.png - - We use a QGridLayout to position our labels and input fields in a - structured manner. QGridLayout divides the available space into a grid and - places widgets in the cells we specify with row and column numbers. The - diagram above shows the layout cells and the position of our widgets, and - we specify this arrangement using the following code: - - \snippet tutorials/addressbook/part1/addressbook.cpp layout - - Notice that \c addressLabel is positioned using Qt::AlignTop as an - additional argument. This is to make sure it is not vertically centered in - cell (1,0). For a basic overview on Qt Layouts, refer to the - \l{Layout Management} documentation. - - In order to install the layout object onto the widget, we have to invoke - the widget's \l{QWidget::setLayout()}{setLayout()} function: - - \snippet tutorials/addressbook/part1/addressbook.cpp setting the layout - - Lastly, we set the widget's title to "Simple Address Book". - - \section1 Running the Application - - A separate file, \c main.cpp, is used for the \c main() function. Within - this function, we instantiate a QApplication object, \c app. QApplication - is responsible for various application-wide resources, such as the default - font and cursor, and for running an event loop. Hence, there is always one - QApplication object in every GUI application using Qt. - - \snippet tutorials/addressbook/part1/main.cpp main function - - We construct a new \c AddressBook widget on the stack and invoke - its \l{QWidget::show()}{show()} function to display it. - However, the widget will not be shown until the application's event loop - is started. We start the event loop by calling the application's - \l{QApplication::}{exec()} function; the result returned by this function - is used as the return value from the \c main() function. At this point, - it becomes apparent why we instanciated \c AddressBook on the stack: It - will now go out of scope. Therefore, \c AddressBook and all its child widgets - will be deleted, thus preventing memory leaks. -*/ - -/*! - \example tutorials/addressbook/part2 - \title Part 2 - Adding Addresses - \brief Describes the code for inserting records in the Address Book Example. - - The next step in creating the address book is to implement some - user interactions. - - \image addressbook-tutorial-part2-add-contact.png - - We will provide a push button that the user can click to add a new contact. - Also, some form of data structure is needed to store these contacts in an - organized way. - - \section1 Defining the AddressBook Class - - Now that we have the labels and input fields set up, we add push buttons to - complete the process of adding a contact. This means that our - \c addressbook.h file now has three QPushButton objects declared and three - corresponding public slots. - - \snippet tutorials/addressbook/part2/addressbook.h slots - - A slot is a function that responds to a particular signal. We will discuss - this concept in further detail when implementing the \c AddressBook class. - However, for an overview of Qt's signals and slots concept, you can refer - to the \l{Signals and Slots} document. - - Three QPushButton objects (\c addButton, \c submitButton, and - \c cancelButton) are now included in our private variable declarations, - along with \c nameLine and \c addressText. - - \snippet tutorials/addressbook/part2/addressbook.h pushbutton declaration - - We need a container to store our address book contacts, so that we can - traverse and display them. A QMap object, \c contacts, is used for this - purpose as it holds a key-value pair: the contact's name as the \e key, - and the contact's address as the \e{value}. - - \snippet tutorials/addressbook/part2/addressbook.h remaining private variables - - We also declare two private QString objects, \c oldName and \c oldAddress. - These objects are needed to hold the name and address of the contact that - was last displayed, before the user clicked \uicontrol Add. So, when the user clicks - \uicontrol Cancel, we can revert to displaying the details of the last contact. - - \section1 Implementing the AddressBook Class - - Within the constructor of \c AddressBook, we set the \c nameLine and - \c addressText to read-only, so that we can only display but not edit - existing contact details. - - \dots - \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 1 - \dots - \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 2 - - Then, we instantiate our push buttons: \c addButton, \c submitButton, and - \c cancelButton. - - \snippet tutorials/addressbook/part2/addressbook.cpp pushbutton declaration - - The \c addButton is displayed by invoking the \l{QPushButton::show()} - {show()} function, while the \c submitButton and \c cancelButton are - hidden by invoking \l{QPushButton::hide()}{hide()}. These two push - buttons will only be displayed when the user clicks \uicontrol Add and this is - handled by the \c addContact() function discussed below. - - \snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots - - We connect the push buttons' \l{QPushButton::clicked()}{clicked()} signal - to their respective slots. The figure below illustrates this. - - \image addressbook-tutorial-part2-signals-and-slots.png - - Next, we arrange our push buttons neatly to the right of our address book - widget, using a QVBoxLayout to line them up vertically. - - \snippet tutorials/addressbook/part2/addressbook.cpp vertical layout - - The \l{QBoxLayout::addStretch()}{addStretch()} function is used to ensure - the push buttons are not evenly spaced, but arranged closer to the top of - the widget. The figure below shows the difference between using - \l{QBoxLayout::addStretch()}{addStretch()} and not using it. - - \image addressbook-tutorial-part2-stretch-effects.png - - We then add \c buttonLayout1 to \c mainLayout, using - \l{QGridLayout::addLayout()}{addLayout()}. This gives us nested layouts - as \c buttonLayout1 is now a child of \c mainLayout. - - \snippet tutorials/addressbook/part2/addressbook.cpp grid layout - - Our layout coordinates now look like this: - - \image addressbook-tutorial-part2-labeled-layout.png - - In the \c addContact() function, we store the last displayed contact - details in \c oldName and \c oldAddress. Then we clear these input - fields and turn off the read-only mode. The focus is set on \c nameLine - and we display \c submitButton and \c cancelButton. - - \snippet tutorials/addressbook/part2/addressbook.cpp addContact - - The \c submitContact() function can be divided into three parts: - - \list 1 - \li We extract the contact's details from \c nameLine and \c addressText - and store them in QString objects. We also validate to make sure that the - user did not click \uicontrol Submit with empty input fields; otherwise, a - QMessageBox is displayed to remind the user for a name and address. - - \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part1 - - \li We then proceed to check if the contact already exists. If it does not - exist, we add the contact to \c contacts and we display a QMessageBox to - inform the user that the contact has been added. - - \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part2 - - If the contact already exists, again, we display a QMessageBox to inform - the user about this, preventing the user from adding duplicate contacts. - Our \c contacts object is based on key-value pairs of name and address, - hence, we want to ensure that \e key is unique. - - \li Once we have handled both cases mentioned above, we restore the push - buttons to their normal state with the following code: - - \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part3 - - \endlist - - The screenshot below shows the QMessageBox object we use to display - information messages to the user. - - \image addressbook-tutorial-part2-add-successful.png - - The \c cancel() function restores the last displayed contact details and - enables \c addButton, as well as hides \c submitButton and - \c cancelButton. - - \snippet tutorials/addressbook/part2/addressbook.cpp cancel - - The general idea behind adding a contact is to give the user the - flexibility to click \uicontrol Submit or \uicontrol Cancel at any time. The flowchart below - further explains this concept: - - \image addressbook-tutorial-part2-add-flowchart.png -*/ - -/*! - \example tutorials/addressbook/part3 - \title Part 3 - Navigating between Entries - \brief Explains the code that enables navigating the contacts. - - The address book is now about half complete. We should add the - capability to navigate the contacts, but first we must - decide what sort of a data structure we need for containing these - contacts. - - In the previous section, we used a QMap of key-value pairs with - the contact's name as the \e key, and the contact's address as the - \e value. This works well for our case. However, in order to - navigate and display each entry, a little bit of enhancement is - needed. - - We enhance the QMap by making it replicate a data structure similar to a - circularly-linked list, where all elements are connected, including the - first element and the last element. The figure below illustrates this data - structure. - - \image addressbook-tutorial-part3-linkedlist.png - - \section1 Defining the AddressBook Class - - To add navigation functions to the address book, we must add two - more slots to the \c AddressBook class: \c next() and \c - previous() to the \c addressbook.h file: - - \snippet tutorials/addressbook/part3/addressbook.h navigation functions - - We also require another two QPushButton objects, so we declare \c nextButton - and \c previousButton as private variables: - - \snippet tutorials/addressbook/part3/addressbook.h navigation pushbuttons - - \section1 Implementing the AddressBook Class - - In the \c AddressBook constructor in \c addressbook.cpp, we instantiate - \c nextButton and \c previousButton and disable them by default. This is - because navigation is only enabled when there is more than one contact - in the address book. - - \snippet tutorials/addressbook/part3/addressbook.cpp navigation pushbuttons - - We then connect these push buttons to their respective slots: - - \snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals - - The image below is the expected graphical user interface. - - \image addressbook-tutorial-part3-screenshot.png - - We follow basic conventions for \c next() and \c previous() functions by - placing the \c nextButton on the right and the \c previousButton on the - left. In order to achieve this intuitive layout, we use QHBoxLayout to - place the widgets side-by-side: - - \snippet tutorials/addressbook/part3/addressbook.cpp navigation layout - - The QHBoxLayout object, \c buttonLayout2, is then added to \c mainLayout. - - \snippet tutorials/addressbook/part3/addressbook.cpp adding navigation layout - - The figure below shows the coordinates of the widgets in \c mainLayout. - \image addressbook-tutorial-part3-labeled-layout.png - - Within our \c addContact() function, we have to disable these buttons so - that the user does not attempt to navigate while adding a contact. - - \snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation - - Also, in our \c submitContact() function, we enable the navigation - buttons, \c nextButton and \c previousButton, depending on the size - of \c contacts. As mentioned earlier, navigation is only enabled when - there is more than one contact in the address book. The following lines - of code demonstrates how to do this: - - \snippet tutorials/addressbook/part3/addressbook.cpp enabling navigation - - We also include these lines of code in the \c cancel() function. - - Recall that we intend to emulate a circularly-linked list with our QMap - object, \c contacts. So, in the \c next() function, we obtain an iterator - for \c contacts and then: - - \list - \li If the iterator is not at the end of \c contacts, we increment it - by one. - \li If the iterator is at the end of \c contacts, we move it to the - beginning of \c contacts. This gives us the illusion that our QMap is - working like a circularly-linked list. - \endlist - - \snippet tutorials/addressbook/part3/addressbook.cpp next() function - - Once we have iterated to the correct object in \c contacts, we display - its contents on \c nameLine and \c addressText. - - Similarly, for the \c previous() function, we obtain an iterator for - \c contacts and then: - - \list - \li If the iterator is at the end of \c contacts, we clear the - display and return. - \li If the iterator is at the beginning of \c contacts, we move it to - the end. - \li We then decrement the iterator by one. - \endlist - - \snippet tutorials/addressbook/part3/addressbook.cpp previous() function - - Again, we display the contents of the current object in \c contacts. - -*/ - -/*! - \example tutorials/addressbook/part4 - \title Part 4 - Editing and Removing Addresses - \brief Explains how to add edit and remove functionality. - - Now we look at ways to modify the contents of contacts stored in - the address book. - - \image addressbook-tutorial-screenshot.png - - We now have an address book that not only holds contacts in an - organized manner, but also allows navigation. It would be - convenient to include edit and remove functions so that a - contact's details can be changed when needed. However, this - requires a little improvement, in the form of enums. We defined - two modes: \c{AddingMode} and \c{NavigationMode}, but they were - not defined as enum values. Instead, we enabled and disabled the - corresponding buttons manually, resulting in multiple lines of - repeated code. - - Here we define the \c Mode enum with three different values: - - \list - \li \c{NavigationMode}, - \li \c{AddingMode}, and - \li \c{EditingMode}. - \endlist - - \section1 Defining the AddressBook Class - - The \c addressbook.h file is updated to contain the \c Mode enum: - - \snippet tutorials/addressbook/part4/addressbook.h Mode enum - - We also add two new slots, \c editContact() and \c removeContact(), to - our current list of public slots. - - \snippet tutorials/addressbook/part4/addressbook.h edit and remove slots - - In order to switch between modes, we introduce the \c updateInterface() function - to control the enabling and disabling of all QPushButton objects. We also - add two new push buttons, \c editButton and \c removeButton, for the edit - and remove functions mentioned earlier. - - \snippet tutorials/addressbook/part4/addressbook.h updateInterface() declaration - \dots - \snippet tutorials/addressbook/part4/addressbook.h buttons declaration - \dots - \snippet tutorials/addressbook/part4/addressbook.h mode declaration - - Lastly, we declare \c currentMode to keep track of the enum's current mode. - - \section1 Implementing the AddressBook Class - - We now implement the mode-changing features of the address - book. The \c editButton and \c removeButton are instantiated and - disabled by default. The address book starts with zero contacts - in memory. - - \snippet tutorials/addressbook/part4/addressbook.cpp edit and remove buttons - - These buttons are then connected to their respective slots, \c editContact() - and \c removeContact(), and we add them to \c buttonLayout1. - - \snippet tutorials/addressbook/part4/addressbook.cpp connecting edit and remove - \dots - \snippet tutorials/addressbook/part4/addressbook.cpp adding edit and remove to the layout - - The \c editContact() function stores the contact's old details in - \c oldName and \c oldAddress, before switching the mode to \c EditingMode. - In this mode, the \c submitButton and \c cancelButton are both enabled, - hence, the user can change the contact's details and click either button. - - \snippet tutorials/addressbook/part4/addressbook.cpp editContact() function - - The \c submitContact() function has been divided in two with an \c{if-else} - statement. We check \c currentMode to see if it's in \c AddingMode. If it is, - we proceed with our adding process. - - \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function beginning - \dots - \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part1 - - Otherwise, we check to see if \c currentMode is in \c EditingMode. If it - is, we compare \c oldName with \c name. If the name has changed, we remove - the old contact from \c contacts and insert the newly updated contact. - - \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part2 - - If only the address has changed (i.e., \c oldAddress is not the same as \c address), - we update the contact's address. Lastly, we set \c currentMode to - \c NavigationMode. This is an important step as it re-enables all the - disabled push buttons. - - To remove a contact from the address book, we implement the - \c removeContact() function. This function checks to see if the contact - exists in \c contacts. - - \snippet tutorials/addressbook/part4/addressbook.cpp removeContact() function - - If it does, we display a QMessageBox, to confirm the removal with the - user. Once the user has confirmed, we call \c previous() to ensure that the - user interface shows another contact, and we remove the contact using \l{QMap}'s - \l{QMap::remove()}{remove()} function. As a courtesy, we display a QMessageBox - to inform the user. Both the message boxes used in this function are shown below: - - \image addressbook-tutorial-part4-remove.png - - \section2 Updating the User Interface - - We mentioned the \c updateInterface() function earlier as a means to - enable and disable the push buttons depending on the current mode. - The function updates the current mode according to the \c mode argument - passed to it, assigning it to \c currentMode before checking its value. - - Each of the push buttons is then enabled or disabled, depending on the - current mode. The code for \c AddingMode and \c EditingMode is shown below: - - \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1 - - For \c NavigationMode, however, we include conditions within the parameters - of the QPushButton::setEnabled() function. This is to ensure that - \c editButton and \c removeButton are enabled when there is at least one - contact in the address book; \c nextButton and \c previousButton are only - enabled when there is more than one contact in the address book. - - \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 2 - - By setting the mode and updating the user interface in the same - function, we avoid the possibility of the user interface getting - out of sync with the internal state of the application. - */ - -/*! - \example tutorials/addressbook/part5 - \title Part 5 - Adding a Find Function - \brief Describes how to add a find function. - - Here we look at ways to locate contacts and addresses in the - address book. - - \image addressbook-tutorial-part5-screenshot.png - - As we add contacts to our address book, it becomes tedious to - navigate the list with the \e Next and \e Previous buttons. A \e - Find function would be more efficient. The screenshot above shows - the \e Find button and its position on the panel of buttons. - - When the user clicks on the \e Find button, it is useful to - display a dialog that prompts for a contact's name. Qt provides - QDialog, which we subclass here to implement a \c FindDialog - class. - - \section1 Defining the FindDialog Class - - \image addressbook-tutorial-part5-finddialog.png - - In order to subclass QDialog, we first include the header for QDialog in - the \c finddialog.h file. Also, we use forward declaration to declare - QLineEdit and QPushButton since we will be using those widgets in our - dialog class. - - As in our \c AddressBook class, the \c FindDialog class includes - the Q_OBJECT macro and its constructor is defined to accept a parent - QWidget, even though the dialog will be opened as a separate window. - - \snippet tutorials/addressbook/part5/finddialog.h FindDialog header - - We define a public function, \c getFindText(), to be used by classes that - instantiate \c FindDialog. This function allows these classes to obtain the - search string entered by the user. A public slot, \c findClicked(), is also - defined to handle the search string when the user clicks the \uicontrol Find - button. - - Lastly, we define the private variables, \c findButton, \c lineEdit - and \c findText, corresponding to the \uicontrol Find button, the line edit - into which the user types the search string, and an internal string - used to store the search string for later use. - - \section1 Implementing the FindDialog Class - - Within the constructor of \c FindDialog, we set up the private variables, - \c lineEdit, \c findButton and \c findText. We use a QHBoxLayout to - position the widgets. - - \snippet tutorials/addressbook/part5/finddialog.cpp constructor - - We set the layout and window title, as well as connect the signals to their - respective slots. Notice that \c{findButton}'s \l{QPushButton::clicked()} - {clicked()} signal is connected to \c findClicked() and - \l{QDialog::accept()}{accept()}. The \l{QDialog::accept()}{accept()} slot - provided by QDialog hides the dialog and sets the result code to - \l{QDialog::}{Accepted}. We use this function to help \c{AddressBook}'s - \c findContact() function know when the \c FindDialog object has been - closed. We will explain this logic in further detail when discussing the - \c findContact() function. - - \image addressbook-tutorial-part5-signals-and-slots.png - - In \c findClicked(), we validate \c lineEdit to ensure that the user - did not click the \uicontrol Find button without entering a contact's name. Then, we set - \c findText to the search string, extracted from \c lineEdit. After that, - we clear the contents of \c lineEdit and hide the dialog. - - \snippet tutorials/addressbook/part5/finddialog.cpp findClicked() function - - The \c findText variable has a public getter function, \c getFindText(), - associated with it. Since we only ever set \c findText directly in both the - constructor and in the \c findClicked() function, we do not create a - setter function to accompany \c getFindText(). - Because \c getFindText() is public, classes instantiating and using - \c FindDialog can always access the search string that the user has - entered and accepted. - - \snippet tutorials/addressbook/part5/finddialog.cpp getFindText() function - - \section1 Defining the AddressBook Class - - To ensure we can use \c FindDialog from within our \c AddressBook class, we - include \c finddialog.h in the \c addressbook.h file. - - \snippet tutorials/addressbook/part5/addressbook.h include finddialog's header - - So far, all our address book features have a QPushButton and a - corresponding slot. Similarly, for the \uicontrol Find feature we have - \c findButton and \c findContact(). - - The \c findButton is declared as a private variable and the - \c findContact() function is declared as a public slot. - - \snippet tutorials/addressbook/part5/addressbook.h findContact() declaration - \dots - \snippet tutorials/addressbook/part5/addressbook.h findButton declaration - - Lastly, we declare the private variable, \c dialog, which we will use to - refer to an instance of \c FindDialog. - - \snippet tutorials/addressbook/part5/addressbook.h FindDialog declaration - - Once we have instantiated a dialog, we will want to use it more than once; - using a private variable allows us to refer to it from more than one place - in the class. - - \section1 Implementing the AddressBook Class - - Within the \c AddressBook class's constructor, we instantiate our private - objects, \c findButton and \c findDialog: - - \snippet tutorials/addressbook/part5/addressbook.cpp instantiating findButton - \dots - \snippet tutorials/addressbook/part5/addressbook.cpp instantiating FindDialog - - Next, we connect the \c{findButton}'s - \l{QPushButton::clicked()}{clicked()} signal to \c findContact(). - - \snippet tutorials/addressbook/part5/addressbook.cpp signals and slots for find - - Now all that is left is the code for our \c findContact() function: - - \snippet tutorials/addressbook/part5/addressbook.cpp findContact() function - - We start out by displaying the \c FindDialog instance, \c dialog. This is - when the user enters a contact name to look up. Once the user clicks - the dialog's \c findButton, the dialog is hidden and the result code is - set to QDialog::Accepted. This ensures that - our \c if statement is always true. - - We then proceed to extract the search string, which in this case is - \c contactName, using \c{FindDialog}'s \c getFindText() function. If the - contact exists in our address book, we display it immediately. Otherwise, - we display the QMessageBox shown below to indicate that their search - failed. - - \image addressbook-tutorial-part5-notfound.png -*/ - -/*! - \example tutorials/addressbook/part6 - \title Part 6 - Loading and Saving - \brief Describes how to add save and load functionality. - - This part covers the Qt file handling features we use to write - loading and saving routines for the address book. - - \image addressbook-tutorial-part6-screenshot.png - - Although browsing and searching the contact list are useful - features, our address book is not complete until we can save - existing contacts and load them again at a later time. - - Qt provides a number of classes for \l{Input/Output and Networking} - {input and output}, but we have chosen to use two which are simple to use - in combination: QFile and QDataStream. - - A QFile object represents a file on disk that can be read from and written - to. QFile is a subclass of the more general QIODevice class which - represents many different kinds of devices. - - A QDataStream object is used to serialize binary data so that it can be - stored in a QIODevice and retrieved again later. Reading from a QIODevice - and writing to it is as simple as opening the stream - with the respective - device as a parameter - and reading from or writing to it. - - - \section1 Defining the AddressBook Class - - We declare two public slots, \c saveToFile() and \c loadFromFile(), as well - as two QPushButton objects, \c loadButton and \c saveButton. - - \snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration - \dots - \snippet tutorials/addressbook/part6/addressbook.h save and load buttons declaration - - \section1 Implementing the AddressBook Class - - In our constructor, we instantiate \c loadButton and \c saveButton. - Ideally, it would be more user-friendly to set the push buttons' labels - to "Load contacts from a file" and "Save contacts to a file". However, due - to the size of our other push buttons, we set the labels to \uicontrol{Load...} - and \uicontrol{Save...}. Fortunately, Qt provides a simple way to set tooltips with - \l{QWidget::setToolTip()}{setToolTip()} and we use it in the following way - for our push buttons: - - \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 1 - \dots - \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2 - - Although it is not shown here, just like the other features we implemented, - we add the push buttons to the layout panel on the right, \c buttonLayout1, - and we connect the push buttons' \l{QPushButton::clicked()}{clicked()} - signals to their respective slots. - - For the saving feature, we first obtain \c fileName using - QFileDialog::getSaveFileName(). This is a convenience function provided - by QFileDialog, which pops up a modal file dialog and allows the user to - enter a file name or select any existing \c{.abk} file. The \c{.abk} file - is our Address Book extension that we create when we save contacts. - - \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part1 - - The file dialog that pops up is displayed in the screenshot below: - - \image addressbook-tutorial-part6-save.png - - If \c fileName is not empty, we create a QFile object, \c file, with - \c fileName. QFile works with QDataStream as QFile is a QIODevice. - - Next, we attempt to open the file in \l{QIODeviceBase::}{WriteOnly} mode. - If this is unsuccessful, we display a QMessageBox to inform the user. - - \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part2 - - Otherwise, we instantiate a QDataStream object, \c out, to write the open - file. QDataStream requires that the same version of the stream is used - for reading and writing. We ensure that this is the case by setting the - version used to the \l{QDataStream::Qt_4_5}{version introduced with Qt 4.5} - before serializing the data to \c file. - - \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part3 - - For the loading feature, we also obtain \c fileName using - QFileDialog::getOpenFileName(). This function, the counterpart to - QFileDialog::getSaveFileName(), also pops up the modal file dialog and - allows the user to enter a file name or select any existing \c{.abk} file - to load it into the address book. - - \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part1 - - On Windows, for example, this function pops up a native file dialog, as - shown in the following screenshot. - - \image addressbook-tutorial-part6-load.png - - If \c fileName is not empty, again, we use a QFile object, \c file, and - attempt to open it in \l{QIODeviceBase::}{ReadOnly} mode. Similar to our - implementation of \c saveToFile(), if this attempt is unsuccessful, we - display a QMessageBox to inform the user. - - \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part2 - - Otherwise, we instantiate a QDataStream object, \c in, set its version as - above and read the serialized data into the \c contacts data structure. - The \c contacts object is emptied before data is read into it to simplify - the file reading process. A more advanced method would be to read the - contacts into a temporary QMap object, and copy over non-duplicate contacts - into \c contacts. - - \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part3 - - To display the contacts that have been read from the file, we must first - validate the data obtained to ensure that the file we read from actually - contains address book contacts. If it does, we display the first contact; - otherwise, we display a QMessageBox to inform the user about the problem. - Lastly, we update the interface to enable and disable the push buttons - accordingly. -*/ - -/*! - \example tutorials/addressbook/part7 - \title Part 7 - Additional Features - \brief Describes how to export data in VCard format. - - This part covers some additional features that make the address - book more convenient for the frequent user. - - \image addressbook-tutorial-part7-screenshot.png - - Although our address book is useful in isolation, it would be - better if we could exchange contact data with other applications. - The vCard format is a popular file format that can be used for - this purpose. Here we extend our address book client to allow - contacts to be exported to vCard \c{.vcf} files. - - \section1 Defining the AddressBook Class - - We add a QPushButton object, \c exportButton, and a corresponding public - slot, \c exportAsVCard() to our \c AddressBook class in the - \c addressbook.h file. - - \snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration - \dots - \snippet tutorials/addressbook/part7/addressbook.h exportButton declaration - - \section1 Implementing the AddressBook Class - - Within the \c AddressBook constructor, we connect \c{exportButton}'s - \l{QPushButton::clicked()}{clicked()} signal to \c exportAsVCard(). - We also add this button to our \c buttonLayout1, the layout responsible - for our panel of buttons on the right. - - In our \c exportAsVCard() function, we start by extracting the contact's - name into \c name. We declare \c firstName, \c lastName and \c nameList. - Next, we look for the index of the first white space in \c name. If there - is a white space, we split the contact's name into \c firstName and - \c lastName. Then, we replace the space with an underscore ("_"). - Alternately, if there is no white space, we assume that the contact only - has a first name. - - \snippet tutorials/addressbook/part7/addressbook.cpp export function part1 - - As with the \c saveToFile() function, we open a file dialog to let the user - choose a location for the file. Using the file name chosen, we create an - instance of QFile to write to. - - We attempt to open the file in \l{QIODeviceBase::}{WriteOnly} mode. If this - process fails, we display a QMessageBox to inform the user about the - problem and return. Otherwise, we pass the file as a parameter to a - QTextStream object, \c out. Like QDataStream, the QTextStream class - provides functionality to read and write plain text to files. As a result, - the \c{.vcf} file generated can be opened for editing in a text editor. - - \snippet tutorials/addressbook/part7/addressbook.cpp export function part2 - - We then write out a vCard file with the \c{BEGIN:VCARD} tag, followed by - the \c{VERSION:2.1} tag. The contact's name is written with the \c{N:} - tag. For the \c{FN:} tag, which fills in the "File as" property of a vCard, - we have to check whether the contact has a last name or not. If the contact - does, we use the details in \c nameList to fill it. Otherwise, we write - \c firstName only. - - \snippet tutorials/addressbook/part7/addressbook.cpp export function part3 - - We proceed to write the contact's address. The semicolons in the address - are escaped with "\\", the newlines are replaced with semicolons, and the - commas are replaced with spaces. Lastly, we write the \c{ADR;HOME:;} - tag, followed by \c address and then the \c{END:VCARD} tag. - - \snippet tutorials/addressbook/part7/addressbook.cpp export function part4 - - In the end, a QMessageBox is displayed to inform the user that the vCard - has been successfully exported. - - \e{vCard is a trademark of the \l{http://www.imc.org} - {Internet Mail Consortium}}. -*/ diff --git a/examples/widgets/doc/src/addressbook.qdoc b/examples/widgets/doc/src/addressbook.qdoc index 22769cb270..24bcee5a26 100644 --- a/examples/widgets/doc/src/addressbook.qdoc +++ b/examples/widgets/doc/src/addressbook.qdoc @@ -1,33 +1,9 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/addressbook - \title Address Book Example + \title Address Book \ingroup examples-itemviews \brief The address book example shows how to use proxy models to display different views onto data from a single model. @@ -48,7 +24,7 @@ \c AddDialog. The \c MainWindow class uses \c AddressWidget as its central widget and provides \uicontrol File and \uicontrol Tools menus. - \image addressbook-classes.png Diagram for Address Book Example + \image addressbook-classes.png Diagram for Address Book example The \c AddressWidget class is a QTabWidget subclass that is used to manipulate the 10 tabs displayed in the example: the 9 @@ -405,17 +381,15 @@ respective slots, we also connect \c AddressWidget's \c selectionChanged() signal to its \c updateActions() slot. - The \c openFile() function allows the user to choose a file with - the \l{QFileDialog::getOpenFileName()}{open file dialog}. The chosen - file has to be a custom \c{.dat} file that contains address book - contacts. This function is a slot connected to \c openAct in the - \uicontrol File menu. + The \c openFile() function opens a custom \c{addressbook.dat} file that + contains address book contacts. This function is a slot connected to + \c openAct in the \uicontrol File menu. \snippet itemviews/addressbook/mainwindow.cpp 2 - The \c saveFile() function allows the user to save a file with - the \l{QFileDialog::getSaveFileName()}{save file dialog}. This function - is a slot connected to \c saveAct in the \uicontrol File menu. + The \c saveFile() function saves a custom \c{addressbook.dat} file that + will contain the address book contacts. This function is a slot connected + to \c saveAct in the \uicontrol File menu. \snippet itemviews/addressbook/mainwindow.cpp 3 diff --git a/examples/widgets/doc/src/affine.qdoc b/examples/widgets/doc/src/affine.qdoc index 601a707eb9..accbf9adfa 100644 --- a/examples/widgets/doc/src/affine.qdoc +++ b/examples/widgets/doc/src/affine.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example painting/affine diff --git a/examples/widgets/doc/src/analogclock.qdoc b/examples/widgets/doc/src/analogclock.qdoc index ff65f97730..27d14be809 100644 --- a/examples/widgets/doc/src/analogclock.qdoc +++ b/examples/widgets/doc/src/analogclock.qdoc @@ -1,33 +1,12 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example widgets/analogclock - \title Analog Clock Example + \examplecategory {Graphics} + \meta tags {widgets} + + \title Analog Clock \ingroup examples-widgets \brief The Analog Clock example shows how to draw the contents of a custom widget. diff --git a/examples/widgets/doc/src/application.qdoc b/examples/widgets/doc/src/application.qdoc deleted file mode 100644 index 334c8cb9f0..0000000000 --- a/examples/widgets/doc/src/application.qdoc +++ /dev/null @@ -1,395 +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 mainwindows/application - \title Qt Widgets - Application Example - \ingroup examples-mainwindow - - \brief The Application example shows how to implement a standard - widget application with menus, toolbars, and a status bar. The example - itself is a simple text editor program built around QPlainTextEdit. - - \image application.png Screenshot of the Application example - - Nearly all of the code for the Application example is in the \c - MainWindow class, which inherits QMainWindow. QMainWindow - provides the framework for windows that have menus, toolbars, - dock windows, and a status bar. The application provides - \uicontrol{File}, \uicontrol{Edit}, and \uicontrol{Help} entries in the menu - bar, with the following popup menus: - - \image application-menus.png The Application example's menu system - - The status bar at the bottom of the main window shows a - description of the menu item or toolbar button under the cursor. - - To keep the example simple, recently opened files aren't shown in - the \uicontrol{File} menu, even though this feature is desired in 90% - of applications. Furthermore, this example can only load one file at a - time. The \l{mainwindows/sdi}{SDI} and \l{mainwindows/mdi}{MDI} examples - show how to lift these restrictions and how to implement recently opened files - handling. - - \section1 MainWindow Class Definition - - Here's the class definition: - - \snippet mainwindows/application/mainwindow.h 0 - - The public API is restricted to the constructor. In the \c - protected section, we reimplement QWidget::closeEvent() to detect - when the user attempts to close the window, and warn the user - about unsaved changes. In the \c{private slots} section, we - declare slots that correspond to menu entries, as well as a - mysterious \c documentWasModified() slot. Finally, in the \c - private section of the class, we have various members that will - be explained in due time. - - \section1 MainWindow Class Implementation - - \snippet mainwindows/application/mainwindow.cpp 0 - - We start by including \c <QtWidgets>, a header file that contains the - definition of all classes in the Qt Core, Qt GUI and Qt Widgets - modules. This saves us from the trouble of having to include - every class individually. We also include \c mainwindow.h. - - You might wonder why we don't include \c <QtWidgets> in \c - mainwindow.h and be done with it. The reason is that including - such a large header from another header file can rapidly degrade - performances. Here, it wouldn't do any harm, but it's still - generally a good idea to include only the header files that are - strictly necessary from another header file. - - \snippet mainwindows/application/mainwindow.cpp 1 - \snippet mainwindows/application/mainwindow.cpp 2 - - In the constructor, we start by creating a QPlainTextEdit widget as a - child of the main window (the \c this object). Then we call - QMainWindow::setCentralWidget() to tell that this is going to be - the widget that occupies the central area of the main window, - between the toolbars and the status bar. - - Then we call \c createActions() and \c createStatusBar(), two private - functions that set up the user interface. After that, we call \c - readSettings() to restore the user's preferences. - - We establish a signal-slot connection between the QPlainTextEdit's - document object and our \c documentWasModified() slot. Whenever - the user modifies the text in the QPlainTextEdit, we want to update - the title bar to show that the file was modified. - - At the end, we set the window title using the private - \c setCurrentFile() function. We'll come back to this later. - - \target close event handler - \snippet mainwindows/application/mainwindow.cpp 3 - \snippet mainwindows/application/mainwindow.cpp 4 - - When the user attempts to close the window, we call the private - function \c maybeSave() to give the user the possibility to save - pending changes. The function returns true if the user wants the - application to close; otherwise, it returns false. In the first - case, we save the user's preferences to disk and accept the close - event; in the second case, we ignore the close event, meaning - that the application will stay up and running as if nothing - happened. - - \snippet mainwindows/application/mainwindow.cpp 5 - \snippet mainwindows/application/mainwindow.cpp 6 - - The \c newFile() slot is invoked when the user selects - \uicontrol{File|New} from the menu. We call \c maybeSave() to save any - pending changes and if the user accepts to go on, we clear the - QPlainTextEdit and call the private function \c setCurrentFile() to - update the window title and clear the - \l{QWidget::windowModified}{windowModified} flag. - - \snippet mainwindows/application/mainwindow.cpp 7 - \snippet mainwindows/application/mainwindow.cpp 8 - - The \c open() slot is invoked when the user clicks - \uicontrol{File|Open}. We pop up a QFileDialog asking the user to - choose a file. If the user chooses a file (i.e., \c fileName is - not an empty string), we call the private function \c loadFile() - to actually load the file. - - \snippet mainwindows/application/mainwindow.cpp 9 - \snippet mainwindows/application/mainwindow.cpp 10 - - The \c save() slot is invoked when the user clicks - \uicontrol{File|Save}. If the user hasn't provided a name for the file - yet, we call \c saveAs(); otherwise, we call the private function - \c saveFile() to actually save the file. - - \snippet mainwindows/application/mainwindow.cpp 11 - \snippet mainwindows/application/mainwindow.cpp 12 - - In \c saveAs(), we start by popping up a QFileDialog asking the - user to provide a name. If the user clicks \uicontrol{Cancel}, the - returned file name is empty, and we do nothing. - - \snippet mainwindows/application/mainwindow.cpp 13 - \snippet mainwindows/application/mainwindow.cpp 14 - - The application's About box is done using one statement, using - the QMessageBox::about() static function and relying on its - support for an HTML subset. - - The \l{QObject::tr()}{tr()} call around the literal string marks - the string for translation. It is a good habit to call - \l{QObject::tr()}{tr()} on all user-visible strings, in case you - later decide to translate your application to other languages. - The \l{Internationalization with Qt} overview covers - \l{QObject::tr()}{tr()} in more detail. - - \snippet mainwindows/application/mainwindow.cpp 15 - \snippet mainwindows/application/mainwindow.cpp 16 - - The \c documentWasModified() slot is invoked each time the text - in the QPlainTextEdit changes because of user edits. We call - QWidget::setWindowModified() to make the title bar show that the - file was modified. How this is done varies on each platform. - - \snippet mainwindows/application/mainwindow.cpp 17 - \snippet mainwindows/application/mainwindow.cpp 18 - \dots - \snippet mainwindows/application/mainwindow.cpp 22 - - The \c createActions() private function, which is called from the - \c MainWindow constructor, creates \l{QAction}s and populates - the menus and two toolbars. The code is very - repetitive, so we show only the actions corresponding to - \uicontrol{File|New}, \uicontrol{File|Open}, and \uicontrol{Help|About Qt}. - - A QAction is an object that represents one user action, such as - saving a file or invoking a dialog. An action can be put in a - QMenu or a QToolBar, or both, or in any other widget that - reimplements QWidget::actionEvent(). - - An action has a text that is shown in the menu, an icon, a - shortcut key, a tooltip, a status tip (shown in the status bar), - a "What's This?" text, and more. It emits a - \l{QAction::triggered()}{triggered()} signal whenever the user - invokes the action (e.g., by clicking the associated menu item or - toolbar button). - - Instances of QAction can be created by passing a parent QObject or - by using one of the convenience functions of QMenu, QMenuBar or QToolBar. - We create the actions that are in a menu as well as in a toolbar - parented on the window to prevent ownership issues. For actions - that are only in the menu, we use the convenience function - QMenu::addAction(), which allows us to pass text, icon and the - target object and its slot member function. - - Creating toolbars is very similar to creating menus. The same - actions that we put in the menus can be reused in the toolbars. - After creating the action, we add it to the toolbar using - QToolBar::addAction(). - - The code above contains one more idiom that must be explained. - For some of the actions, we specify an icon as a QIcon to the - QAction constructor. We use QIcon::fromTheme() to obtain - the correct standard icon from the underlying window system. - If that fails due to the platform not supporting it, we - pass a file name as fallback. Here, the file name starts - with \c{:}. Such file names aren't ordinary file names, but - rather path in the executable's stored resources. We'll come back - to this when we review the \c application.qrc file that's part of - the project. - - \snippet mainwindows/application/mainwindow.cpp 23 - \snippet mainwindows/application/mainwindow.cpp 24 - - The \uicontrol{Edit|Cut} and \uicontrol{Edit|Copy} actions must be available - only when the QPlainTextEdit contains selected text. We disable them - by default and connect the QPlainTextEdit::copyAvailable() signal to - the QAction::setEnabled() slot, ensuring that the actions are - disabled when the text editor has no selection. - - Just before we create the \uicontrol{Help} menu, we call - QMenuBar::addSeparator(). This has no effect for most widget - styles (e.g., Windows and \macos styles), but for some - styles this makes sure that \uicontrol{Help} is pushed to the right - side of the menu bar. - - \snippet mainwindows/application/mainwindow.cpp 32 - \snippet mainwindows/application/mainwindow.cpp 33 - - QMainWindow::statusBar() returns a pointer to the main window's - QStatusBar widget. Like with \l{QMainWindow::menuBar()}, the - widget is automatically created the first time the function is - called. - - \snippet mainwindows/application/mainwindow.cpp 34 - \snippet mainwindows/application/mainwindow.cpp 36 - - The \c readSettings() function is called from the constructor to - load the user's preferences and other application settings. The - QSettings class provides a high-level interface for storing - settings permanently on disk. On Windows, it uses the (in)famous - Windows registry; on \macos, it uses the native XML-based - CFPreferences API; on Unix/X11, it uses text files. - - The QSettings constructor takes arguments that identify your - company and the name of the product. This ensures that the - settings for different applications are kept separately. - - We use QSettings::value() to extract the value of the geometry setting. - The second argument to QSettings::value() is - optional and specifies a default value for the setting if there - exists none. This value is used the first time the application is - run. - - We use QWidget::saveGeometry() and Widget::restoreGeometry() to - save the position. They use an opaque QByteArray to store - screen number, geometry and window state. - - \snippet mainwindows/application/mainwindow.cpp 37 - \snippet mainwindows/application/mainwindow.cpp 39 - - The \c writeSettings() function is called from \c closeEvent(). - Writing settings is similar to reading them, except simpler. The - arguments to the QSettings constructor must be the same as in \c - readSettings(). - - \snippet mainwindows/application/mainwindow.cpp 40 - \snippet mainwindows/application/mainwindow.cpp 41 - - The \c maybeSave() function is called to save pending changes. If - there are pending changes, it pops up a QMessageBox giving the - user to save the document. The options are QMessageBox::Yes, - QMessageBox::No, and QMessageBox::Cancel. The \uicontrol{Yes} button is - made the default button (the button that is invoked when the user - presses \uicontrol{Return}) using the QMessageBox::Default flag; the - \uicontrol{Cancel} button is made the escape button (the button that is - invoked when the user presses \uicontrol{Esc}) using the - QMessageBox::Escape flag. - - The \c maybeSave() function returns \c true in all cases, except - when the user clicks \uicontrol{Cancel} or saving the file fails. - The caller must check the return value and stop whatever it was - doing if the return value is \c false. - - \snippet mainwindows/application/mainwindow.cpp 42 - \snippet mainwindows/application/mainwindow.cpp 43 - - In \c loadFile(), we use QFile and QTextStream to read in the - data. The QFile object provides access to the bytes stored in a - file. - - We start by opening the file in read-only mode. The QFile::Text - flag indicates that the file is a text file, not a binary file. - On Unix and \macos, this makes no difference, but on Windows, - it ensures that the "\\r\\n" end-of-line sequence is converted to - "\\n" when reading. - - If we successfully opened the file, we use a QTextStream object - to read in the data. QTextStream automatically converts the 8-bit - data into a Unicode QString and supports various encodings. If no - encoding is specified, QTextStream assumes the file is encoded in - UTF-8. - - Since the call to QTextStream::readAll() might take some time, we - set the cursor to be Qt::WaitCursor for the entire application - while it goes on. - - At the end, we call the private \c setCurrentFile() function, - which we'll cover in a moment, and we display the string "File - loaded" in the status bar for 2 seconds (2000 milliseconds). - - \snippet mainwindows/application/mainwindow.cpp 44 - \snippet mainwindows/application/mainwindow.cpp 45 - - Saving a file is similar to loading one. We use QSaveFile to ensure - all data are safely written and existing files are not damaged - should writing fail. - We use the QFile::Text flag to make sure that on Windows, "\\n" - is converted into "\\r\\n" to conform to the Windows convention. - - - \snippet mainwindows/application/mainwindow.cpp 46 - \snippet mainwindows/application/mainwindow.cpp 47 - - The \c setCurrentFile() function is called to reset the state of - a few variables when a file is loaded or saved, or when the user - starts editing a new file (in which case \c fileName is empty). - We update the \c curFile variable, clear the - QTextDocument::modified flag and the associated \c - QWidget:windowModified flag, and update the window title to - contain the new file name (or \c untitled.txt). - - The \c strippedName() function call around \c curFile in the - QWidget::setWindowTitle() call shortens the file name to exclude - the path. Here's the function: - - \snippet mainwindows/application/mainwindow.cpp 48 - \snippet mainwindows/application/mainwindow.cpp 49 - - \section1 The main() Function - - The \c main() function for this application is typical of - applications that contain one main window: - - \snippet mainwindows/application/main.cpp 0 - - The main function uses QCommandLineParser to check whether some file - argument was passed to the application and loads it via - MainWindow::loadFile(). - - \section1 The Resource File - - As you will probably recall, for some of the actions, we - specified icons with file names starting with \c{:} and mentioned - that such file names aren't ordinary file names, but path in the - executable's stored resources. These resources are compiled - - The resources associated with an application are specified in a - \c .qrc file, an XML-based file format that lists files on the - disk. Here's the \c application.qrc file that's used by the - Application example: - - \quotefile mainwindows/application/application.qrc - - The \c .png files listed in the \c application.qrc file are files - that are part of the Application example's source tree. Paths are - relative to the directory where the \c application.qrc file is - located (the \c mainwindows/application directory). - - The resource file must be mentioned in the \c application.pro - file so that \c qmake knows about it: - - \snippet mainwindows/application/application.pro 0 - - \c qmake will produce make rules to generate a file called \c - qrc_application.cpp that is linked into the application. This - file contains all the data for the images and other resources as - static C++ arrays of compressed binary data. See - \l{resources.html}{The Qt Resource System} for more information - about resources. -*/ diff --git a/examples/widgets/doc/src/basicdrawing.qdoc b/examples/widgets/doc/src/basicdrawing.qdoc index 3eda3ffed2..7413dfc823 100644 --- a/examples/widgets/doc/src/basicdrawing.qdoc +++ b/examples/widgets/doc/src/basicdrawing.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example painting/basicdrawing diff --git a/examples/widgets/doc/src/basicgraphicslayouts.qdoc b/examples/widgets/doc/src/basicgraphicslayouts.qdoc index 23661d0558..ce7176bf7f 100644 --- a/examples/widgets/doc/src/basicgraphicslayouts.qdoc +++ b/examples/widgets/doc/src/basicgraphicslayouts.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/basicgraphicslayouts diff --git a/examples/widgets/doc/src/basiclayouts.qdoc b/examples/widgets/doc/src/basiclayouts.qdoc index e9d7cea21b..c55514689d 100644 --- a/examples/widgets/doc/src/basiclayouts.qdoc +++ b/examples/widgets/doc/src/basiclayouts.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example layouts/basiclayouts diff --git a/examples/widgets/doc/src/basicsortfiltermodel.qdoc b/examples/widgets/doc/src/basicsortfiltermodel.qdoc index d598ab1e24..969ee0a9d5 100644 --- a/examples/widgets/doc/src/basicsortfiltermodel.qdoc +++ b/examples/widgets/doc/src/basicsortfiltermodel.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/basicsortfiltermodel diff --git a/examples/widgets/doc/src/blurpicker.qdoc b/examples/widgets/doc/src/blurpicker.qdoc deleted file mode 100644 index d4d84f7248..0000000000 --- a/examples/widgets/doc/src/blurpicker.qdoc +++ /dev/null @@ -1,44 +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 effects/blurpicker - \title Blur Picker Effect Example - \ingroup examples-graphicsview-graphicseffects - \brief Demonstrates how to apply graphical effects on items in the view. - - \image blurpickereffect-example.png - - The Blur Picker example displays a circle of application icons. - All icons are blurred, except the one on the bottom left side of - the screen, which is the one in focus. - Clicking anywhere on the left side of the screen moves the icon - circle clockwise to the next icon - Clicking on the right side advances the circle counterclockwise. - - \sa QGraphicsBlurEffect -*/ diff --git a/examples/widgets/doc/src/borderlayout.qdoc b/examples/widgets/doc/src/borderlayout.qdoc index 6572bfe578..9ec5e96d78 100644 --- a/examples/widgets/doc/src/borderlayout.qdoc +++ b/examples/widgets/doc/src/borderlayout.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example layouts/borderlayout diff --git a/examples/widgets/doc/src/calculator.qdoc b/examples/widgets/doc/src/calculator.qdoc index 7d34a86c19..cc015e46a0 100644 --- a/examples/widgets/doc/src/calculator.qdoc +++ b/examples/widgets/doc/src/calculator.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example widgets/calculator diff --git a/examples/widgets/doc/src/calendar.qdoc b/examples/widgets/doc/src/calendar.qdoc index 4a6a482ff2..218ea5ea0c 100644 --- a/examples/widgets/doc/src/calendar.qdoc +++ b/examples/widgets/doc/src/calendar.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example richtext/calendar diff --git a/examples/widgets/doc/src/calendarwidget.qdoc b/examples/widgets/doc/src/calendarwidget.qdoc index c04fab1fc7..6a91f5ef6e 100644 --- a/examples/widgets/doc/src/calendarwidget.qdoc +++ b/examples/widgets/doc/src/calendarwidget.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \title Calendar Widget Example diff --git a/examples/widgets/doc/src/charactermap.qdoc b/examples/widgets/doc/src/charactermap.qdoc index 3cf4a1210b..ee6162302f 100644 --- a/examples/widgets/doc/src/charactermap.qdoc +++ b/examples/widgets/doc/src/charactermap.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example widgets/charactermap @@ -195,7 +171,7 @@ QScrollArea provides a viewport onto the \c CharacterWidget when we set its widget and handles much of the work needed to provide a scrolling viewport. -The font combo box is automatically popuplated with a list of available +The font combo box is automatically populated with a list of available fonts. We list the available styles for the current font in the style combobox using the following function: diff --git a/examples/widgets/doc/src/chart.qdoc b/examples/widgets/doc/src/chart.qdoc index e721832c5b..abb1b3ab7e 100644 --- a/examples/widgets/doc/src/chart.qdoc +++ b/examples/widgets/doc/src/chart.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/chart diff --git a/examples/widgets/doc/src/chip.qdoc b/examples/widgets/doc/src/chip.qdoc index 758b692f0e..a76e11950e 100644 --- a/examples/widgets/doc/src/chip.qdoc +++ b/examples/widgets/doc/src/chip.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/chip diff --git a/examples/widgets/doc/src/classwizard.qdoc b/examples/widgets/doc/src/classwizard.qdoc deleted file mode 100644 index 7f3693b65e..0000000000 --- a/examples/widgets/doc/src/classwizard.qdoc +++ /dev/null @@ -1,191 +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 dialogs/classwizard - \title Class Wizard Example - \ingroup examples-dialogs - - \brief The Class Wizard example shows how to implement linear - wizards using QWizard. - - \image classwizard.png Screenshot of the Class Wizard example - - Most wizards have a linear structure, with page 1 followed by - page 2 and so on until the last page. Some wizards are more - complex in that they allow different traversal paths based on the - information provided by the user. The - \l{dialogs/licensewizard}{License Wizard} example shows how to - create such wizards. - - The Class Wizard example consists of the following classes: - - \list - \li \c ClassWizard inherits QWizard and provides a - three-step wizard that generates the skeleton of a C++ class - based on the user's input. - \li \c IntroPage, \c ClassInfoPage, \c CodeStylePage, \c - OutputFilesPage, and \c ConclusionPage are QWizardPage - subclasses that implement the wizard pages. - \endlist - - \section1 ClassWizard Class Definition - - \image classwizard-flow.png The Class Wizard pages - - We will see how to subclass QWizard to implement our own wizard. - The concrete wizard class is called \c ClassWizard and provides - five pages: - - \list - \li The first page is an introduction page, telling the user what - the wizard is going to do. - \li The second page asks for a class name and a base class, and - allows the user to specify whether the class should have a \c - Q_OBJECT macro and what constructors it should provide. - \li The third page allows the user to set some options related to the code - style, such as the macro used to protect the header file from - multiple inclusion (e.g., \c MYDIALOG_H). - \li The fourth page allows the user to specify the names of the - output files. - \li The fifth page is a conclusion page. - \endlist - - Although the program is just an example, if you press \uicontrol Finish - (\uicontrol Done on \macos), actual C++ source files will actually be - generated. - - \section1 The ClassWizard Class - - Here's the \c ClassWizard definition: - - \snippet dialogs/classwizard/classwizard.h 0 - - The class reimplements QDialog's \l{QDialog::}{accept()} slot. - This slot is called when the user clicks \uicontrol{Finish}. - - Here's the constructor: - - \snippet dialogs/classwizard/classwizard.cpp 1 - - We instantiate the five pages and insert them into the wizard - using QWizard::addPage(). The order in which they are inserted - is also the order in which they will be shown later on. - - We call QWizard::setPixmap() to set the banner and the - background pixmaps for all pages. The banner is used as a - background for the page header when the wizard's style is - \l{QWizard::}{ModernStyle}; the background is used as the - dialog's background in \l{QWizard::}{MacStyle}. (See \l{Elements - of a Wizard Page} for more information.) - - \snippet dialogs/classwizard/classwizard.cpp 3 - \snippet dialogs/classwizard/classwizard.cpp 4 - \dots - \snippet dialogs/classwizard/classwizard.cpp 5 - \snippet dialogs/classwizard/classwizard.cpp 6 - - If the user clicks \uicontrol Finish, we extract the information from - the various pages using QWizard::field() and generate the files. - The code is long and tedious (and has barely anything to do with - noble art of designing wizards), so most of it is skipped here. - See the actual example in the Qt distribution for the details if - you're curious. - - \section1 The IntroPage Class - - The pages are defined in \c classwizard.h and implemented in \c - classwizard.cpp, together with \c ClassWizard. We will start with - the easiest page: - - \snippet dialogs/classwizard/classwizard.h 1 - \codeline - \snippet dialogs/classwizard/classwizard.cpp 7 - - A page inherits from QWizardPage. We set a - \l{QWizardPage::}{title} and a - \l{QWizard::WatermarkPixmap}{watermark pixmap}. By not setting - any \l{QWizardPage::}{subTitle}, we ensure that no header is - displayed for this page. (On Windows, it is customary for wizards - to display a watermark pixmap on the first and last pages, and to - have a header on the other pages.) - - Then we create a QLabel and add it to a layout. - - \section1 The ClassInfoPage Class - - The second page is defined and implemented as follows: - - \snippet dialogs/classwizard/classwizard.h 2 - \codeline - \snippet dialogs/classwizard/classwizard.cpp 9 - \dots - \snippet dialogs/classwizard/classwizard.cpp 12 - \dots - \snippet dialogs/classwizard/classwizard.cpp 13 - - First, we set the page's \l{QWizardPage::}{title}, - \l{QWizardPage::}{subTitle}, and \l{QWizard::LogoPixmap}{logo - pixmap}. The logo pixmap is displayed in the page's header in - \l{QWizard::}{ClassicStyle} and \l{QWizard::}{ModernStyle}. - - Then we create the child widgets, create \l{Registering and Using - Fields}{wizard fields} associated with them, and put them into - layouts. The \c className field is created with an asterisk (\c - *) next to its name. This makes it a \l{mandatory fields}{mandatory field}, that - is, a field that must be filled before the user can press the - \uicontrol Next button (\uicontrol Continue on \macos). The fields' values - can be accessed from any other page using QWizardPage::field(), - or from the wizard code using QWizard::field(). - - \section1 The CodeStylePage Class - - The third page is defined and implemented as follows: - - \snippet dialogs/classwizard/classwizard.h 3 - \codeline - \snippet dialogs/classwizard/classwizard.cpp 14 - \dots - \snippet dialogs/classwizard/classwizard.cpp 15 - \codeline - \snippet dialogs/classwizard/classwizard.cpp 16 - - The code in the constructor is very similar to what we did for \c - ClassInfoPage, so we skipped most of it. - - The \c initializePage() function is what makes this class - interesting. It is reimplemented from QWizardPage and is used to - initialize some of the page's fields with values from the - previous page (namely, \c className and \c baseClass). For - example, if the class name on page 2 is \c SuperDuperWidget, the - default macro name on page 3 is \c SUPERDUPERWIDGET_H. - - The \c OutputFilesPage and \c ConclusionPage classes are very - similar to \c CodeStylePage, so we won't review them here. - - \sa QWizard, {License Wizard Example}, {Trivial Wizard Example} -*/ diff --git a/examples/widgets/doc/src/codeeditor.qdoc b/examples/widgets/doc/src/codeeditor.qdoc deleted file mode 100644 index 7f09f4bba0..0000000000 --- a/examples/widgets/doc/src/codeeditor.qdoc +++ /dev/null @@ -1,197 +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 widgets/codeeditor - \title Code Editor Example - \ingroup examples-widgets - \brief The Code Editor example shows how to create a simple editor that - has line numbers and that highlights the current line. - - \borderedimage codeeditor-example.png - - As can be seen from the image, the editor displays the line - numbers in an area to the left of the area for editing. The editor - will highlight the line containing the cursor. - - We implement the editor in \c CodeEditor, which is a widget that - inherits QPlainTextEdit. We keep a separate widget in \c - CodeEditor (\c LineNumberArea) onto which we draw the line - numbers. - - QPlainTextEdit inherits from QAbstractScrollArea, and editing - takes place within its \l{QAbstractScrollArea::}{viewport()}'s - margins. We make room for our line number area by setting the left - margin of the viewport to the size we need to draw the line - numbers. - - When it comes to editing code, we prefer QPlainTextEdit over - QTextEdit because it is optimized for handling plain text. See - the QPlainTextEdit class description for details. - - QPlainTextEdit lets us add selections in addition to the - selection the user can make with the mouse or keyboard. We use - this functionality to highlight the current line. More on this - later. - - We will now move on to the definitions and implementations of \c - CodeEditor and \c LineNumberArea. Let's start with the \c - LineNumberArea class. - - \section1 The LineNumberArea Class - - We paint the line numbers on this widget, and place it over the \c - CodeEditor's \l{QAbstractScrollArea::}{viewport()}'s left margin - area. - - We need to use protected functions in QPlainTextEdit while - painting the area. So to keep things simple, we paint the area in - the \c CodeEditor class. The area also asks the editor to - calculate its size hint. - - Note that we could simply paint the line numbers directly on the - code editor, and drop the LineNumberArea class. However, the - QWidget class helps us to \l{QWidget::}{scroll()} its contents. - Also, having a separate widget is the right choice if we wish to - extend the editor with breakpoints or other code editor features. - The widget would then help in the handling of mouse events. - - \snippet widgets/codeeditor/codeeditor.h extraarea - - \section1 CodeEditor Class Definition - - Here is the code editor's class definition: - - \snippet widgets/codeeditor/codeeditor.h codeeditordefinition - - In the editor we resize and draw the line numbers on the \c - LineNumberArea. We need to do this when the number of lines in the - editor changes, and when the editor's viewport() is scrolled. Of - course, it is also done when the editor's size changes. We do - this in \c updateLineNumberWidth() and \c updateLineNumberArea(). - - Whenever, the cursor's position changes, we highlight the current - line in \c highlightCurrentLine(). - - \section1 CodeEditor Class Implementation - - We will now go through the code editors implementation, starting - off with the constructor. - - \snippet widgets/codeeditor/codeeditor.cpp constructor - - In the constructor we connect our slots to signals in - QPlainTextEdit. It is necessary to calculate the line number area - width and highlight the first line when the editor is created. - - \snippet widgets/codeeditor/codeeditor.cpp extraAreaWidth - - The \c lineNumberAreaWidth() function calculates the width of the - \c LineNumberArea widget. We take the number of digits in the last - line of the editor and multiply that with the maximum width of a - digit. - - \snippet widgets/codeeditor/codeeditor.cpp slotUpdateExtraAreaWidth - - When we update the width of the line number area, we simply call - QAbstractScrollArea::setViewportMargins(). - - \snippet widgets/codeeditor/codeeditor.cpp slotUpdateRequest - - This slot is invoked when the editors viewport has been scrolled. - The QRect given as argument is the part of the editing area that - is do be updated (redrawn). \c dy holds the number of pixels the - view has been scrolled vertically. - - \snippet widgets/codeeditor/codeeditor.cpp resizeEvent - - When the size of the editor changes, we also need to resize the - line number area. - - \snippet widgets/codeeditor/codeeditor.cpp cursorPositionChanged - - When the cursor position changes, we highlight the current line, - i.e., the line containing the cursor. - - QPlainTextEdit gives the possibility to have more than one - selection at the same time. we can set the character format - (QTextCharFormat) of these selections. We clear the cursors - selection before setting the new new - QPlainTextEdit::ExtraSelection, else several lines would get - highlighted when the user selects multiple lines with the mouse. - \omit ask someone how this works \endomit - - One sets the selection with a text cursor. When using the - FullWidthSelection property, the current cursor text block (line) - will be selected. If you want to select just a portion of the text - block, the cursor should be moved with QTextCursor::movePosition() - from a position set with \l{QTextCursor::}{setPosition()}. - - \snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_0 - - The \c lineNumberAreaPaintEvent() is called from \c LineNumberArea - whenever it receives a paint event. We start off by painting the - widget's background. - - \snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_1 - - We will now loop through all visible lines and paint the line - numbers in the extra area for each line. Notice that in a plain - text edit each line will consist of one QTextBlock; though, if - line wrapping is enabled, a line may span several rows in the text - edit's viewport. - - We get the top and bottom y-coordinate of the first text block, - and adjust these values by the height of the current text block in - each iteration in the loop. - - \snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_2 - - Notice that we check if the block is visible in addition to check - if it is in the areas viewport - a block can, for example, be - hidden by a window placed over the text edit. - - \section1 Suggestions for Extending the Code Editor - - No self-respecting code editor is without a syntax - highligther; the \l{Syntax Highlighter Example} shows how to - create one. - - In addition to line numbers, you can add more to the extra area, - for instance, break points. - - QSyntaxHighlighter gives the possibility to add user data to each - text block with - \l{QSyntaxHighlighter::}{setCurrentBlockUserData()}. This can be - used to implement parenthesis matching. In the \c - highlightCurrentLine(), the data of the currentBlock() can be - fetched with QTextBlock::userData(). Matching parentheses can be - highlighted with an extra selection. The "Matching Parentheses - with QSyntaxHighlighter" article in Qt Quarterly 31 implements - this. You find it here: \l{http://doc.qt.io/archives/qq/}. - -*/ diff --git a/examples/widgets/doc/src/collidingmice-example.qdoc b/examples/widgets/doc/src/collidingmice-example.qdoc index 984d3244f9..4f6859406e 100644 --- a/examples/widgets/doc/src/collidingmice-example.qdoc +++ b/examples/widgets/doc/src/collidingmice-example.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/collidingmice @@ -161,7 +137,7 @@ Because the complexity of arbitrary shape-shape intersection grows with an order of magnitude when the shapes are complex, this - operation can be noticably time consuming. An alternative approach + operation can be noticeably time consuming. An alternative approach is to reimplement the \l {QGraphicsItem::collidesWithItem()}{collidesWithItem()} function to provide your own custom item and shape collision algorithm. diff --git a/examples/widgets/doc/src/coloreditorfactory.qdoc b/examples/widgets/doc/src/coloreditorfactory.qdoc index 1471f75e78..a7da4d6847 100644 --- a/examples/widgets/doc/src/coloreditorfactory.qdoc +++ b/examples/widgets/doc/src/coloreditorfactory.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/coloreditorfactory diff --git a/examples/widgets/doc/src/combowidgetmapper.qdoc b/examples/widgets/doc/src/combowidgetmapper.qdoc index d1b8948b6d..2f53bfd11b 100644 --- a/examples/widgets/doc/src/combowidgetmapper.qdoc +++ b/examples/widgets/doc/src/combowidgetmapper.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/combowidgetmapper diff --git a/examples/widgets/doc/src/completer.qdoc b/examples/widgets/doc/src/completer.qdoc index 8c6b0246ea..a64d7e1e79 100644 --- a/examples/widgets/doc/src/completer.qdoc +++ b/examples/widgets/doc/src/completer.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example tools/completer diff --git a/examples/widgets/doc/src/composition.qdoc b/examples/widgets/doc/src/composition.qdoc index 89669e7daa..99fc066110 100644 --- a/examples/widgets/doc/src/composition.qdoc +++ b/examples/widgets/doc/src/composition.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example painting/composition diff --git a/examples/widgets/doc/src/concentriccircles.qdoc b/examples/widgets/doc/src/concentriccircles.qdoc index fdf1f88142..ffdb09869f 100644 --- a/examples/widgets/doc/src/concentriccircles.qdoc +++ b/examples/widgets/doc/src/concentriccircles.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example painting/concentriccircles diff --git a/examples/widgets/doc/src/customsortfiltermodel.qdoc b/examples/widgets/doc/src/customsortfiltermodel.qdoc index ebbd29a921..5ee98362ba 100644 --- a/examples/widgets/doc/src/customsortfiltermodel.qdoc +++ b/examples/widgets/doc/src/customsortfiltermodel.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/customsortfiltermodel diff --git a/examples/widgets/doc/src/deform.qdoc b/examples/widgets/doc/src/deform.qdoc index db7d7a82c9..371f1a41c7 100644 --- a/examples/widgets/doc/src/deform.qdoc +++ b/examples/widgets/doc/src/deform.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example painting/deform diff --git a/examples/widgets/doc/src/diagramscene.qdoc b/examples/widgets/doc/src/diagramscene.qdoc index 6a38ebd2c5..057031462d 100644 --- a/examples/widgets/doc/src/diagramscene.qdoc +++ b/examples/widgets/doc/src/diagramscene.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/diagramscene @@ -313,7 +289,7 @@ added to the scene. We set the mode of the scene back to the mode before the item was inserted, which is ItemMove or InsertText depending on which button is checked in the \c pointerTypeGroup. - We must also uncheck the button in the in the \c buttonGroup. + We must also uncheck the button in the \c buttonGroup. Here is the implementation of \c textInserted(): diff --git a/examples/widgets/doc/src/digitalclock.qdoc b/examples/widgets/doc/src/digitalclock.qdoc index aff349adb8..d24277177f 100644 --- a/examples/widgets/doc/src/digitalclock.qdoc +++ b/examples/widgets/doc/src/digitalclock.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example widgets/digitalclock diff --git a/examples/widgets/doc/src/dirview.qdoc b/examples/widgets/doc/src/dirview.qdoc index d8c68bf41e..5c63d99eaa 100644 --- a/examples/widgets/doc/src/dirview.qdoc +++ b/examples/widgets/doc/src/dirview.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/dirview diff --git a/examples/widgets/doc/src/dockwidgets.qdoc b/examples/widgets/doc/src/dockwidgets.qdoc index 34190f6d2e..9907cea2e2 100644 --- a/examples/widgets/doc/src/dockwidgets.qdoc +++ b/examples/widgets/doc/src/dockwidgets.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example mainwindows/dockwidgets diff --git a/examples/widgets/doc/src/draganddroppuzzle.qdoc b/examples/widgets/doc/src/draganddroppuzzle.qdoc index b318cc2fb9..c2504b245b 100644 --- a/examples/widgets/doc/src/draganddroppuzzle.qdoc +++ b/examples/widgets/doc/src/draganddroppuzzle.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example draganddrop/puzzle diff --git a/examples/widgets/doc/src/dragdroprobot.qdoc b/examples/widgets/doc/src/dragdroprobot.qdoc index ac138072c9..ca62bf73df 100644 --- a/examples/widgets/doc/src/dragdroprobot.qdoc +++ b/examples/widgets/doc/src/dragdroprobot.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/dragdroprobot @@ -319,7 +295,7 @@ This snippet has a somewhat random outcome: once in a while, a special image is assigned to the drag object's mime data. The pixmap is also - assiged as the drag object's pixmap. This will ensure that you can see the + assigned as the drag object's pixmap. This will ensure that you can see the image that is being dragged as a pixmap under the mouse cursor. \snippet graphicsview/dragdroprobot/coloritem.cpp 7 diff --git a/examples/widgets/doc/src/draggableicons.qdoc b/examples/widgets/doc/src/draggableicons.qdoc index 7c5b5dc574..9a0290c82f 100644 --- a/examples/widgets/doc/src/draggableicons.qdoc +++ b/examples/widgets/doc/src/draggableicons.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example draganddrop/draggableicons diff --git a/examples/widgets/doc/src/draggabletext.qdoc b/examples/widgets/doc/src/draggabletext.qdoc index e934119e7a..3cc3560bb9 100644 --- a/examples/widgets/doc/src/draggabletext.qdoc +++ b/examples/widgets/doc/src/draggabletext.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example draganddrop/draggabletext diff --git a/examples/widgets/doc/src/dynamiclayouts.qdoc b/examples/widgets/doc/src/dynamiclayouts.qdoc index 0b9d43c98e..5dea8a7f6a 100644 --- a/examples/widgets/doc/src/dynamiclayouts.qdoc +++ b/examples/widgets/doc/src/dynamiclayouts.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example layouts/dynamiclayouts diff --git a/examples/widgets/doc/src/easing.qdoc b/examples/widgets/doc/src/easing.qdoc index 807dd72e93..c9f8752b93 100644 --- a/examples/widgets/doc/src/easing.qdoc +++ b/examples/widgets/doc/src/easing.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example animation/easing diff --git a/examples/widgets/doc/src/echoplugin.qdoc b/examples/widgets/doc/src/echoplugin.qdoc index 28be789c5c..4cdd700534 100644 --- a/examples/widgets/doc/src/echoplugin.qdoc +++ b/examples/widgets/doc/src/echoplugin.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example tools/echoplugin diff --git a/examples/widgets/doc/src/editabletreemodel.qdoc b/examples/widgets/doc/src/editabletreemodel.qdoc index 68e10e3e78..9616610758 100644 --- a/examples/widgets/doc/src/editabletreemodel.qdoc +++ b/examples/widgets/doc/src/editabletreemodel.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/editabletreemodel @@ -108,7 +84,7 @@ \l{TreeItem::data}{data()} function to read entries in the \c itemData list and a \l{TreeItem::setData}{setData()} function to allow them to be modified. - As with other functions in the item, this simplifies the implemention + As with other functions in the item, this simplifies the implementation of the model's \l{QAbstractItemModel::}{data()} and \l{QAbstractItemModel::}{setData()} functions. diff --git a/examples/widgets/doc/src/elasticnodes.qdoc b/examples/widgets/doc/src/elasticnodes.qdoc index e78db67be2..1d155adbec 100644 --- a/examples/widgets/doc/src/elasticnodes.qdoc +++ b/examples/widgets/doc/src/elasticnodes.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/elasticnodes @@ -259,7 +235,7 @@ This ensures that the edge items are not considered for mouse input at all (i.e., you cannot click the edges). Then, the source and destination pointers are updated, this edge is registered with each node, and we call - \c adjust() to update this edge's start end end position. + \c adjust() to update this edge's start and end position. \snippet graphicsview/elasticnodes/edge.cpp 1 @@ -355,7 +331,7 @@ collection of small items that all move around, it's unnecessary for Graphics View to waste time finding accurate update regions, so we set the QGraphicsView::BoundingRectViewportUpdate viewport update mode. The default - would work fine, but this mode is noticably faster for this example. + would work fine, but this mode is noticeably faster for this example. To improve rendering quality, we set QPainter::Antialiasing. diff --git a/examples/widgets/doc/src/elidedlabel.qdoc b/examples/widgets/doc/src/elidedlabel.qdoc deleted file mode 100644 index b731b60e83..0000000000 --- a/examples/widgets/doc/src/elidedlabel.qdoc +++ /dev/null @@ -1,155 +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 widgets/elidedlabel - \title Elided Label Example - - \brief This example creates a widget similar to QLabel, that elides the last - visible line, if the text is too long to fit the widget's geometry. - - \image elidedlabel-example.png Elided Label example on XPressMusic 5800 - - When text of varying length has to be displayed in a uniformly sized - area, for instance within a list or grid view where all list items have the - same size, it can be useful to give the user a visual clue when not all - text is visible. QLabel can elide text that doesn't fit within it, but only - in one line. The \c ElidedLabel widget shown in this example word wraps its - text by its width, and elides the last visible line if some text is left - out. \c TestWidget gives control to the features of \c ElidedWidget and - forms the example application. - - - \section1 ElidedLabel Class Definition - - Like QLabel, \c ElidedLabel inherits from QFrame. Here's the definition of - the \c ElidedLabel class: - - - \snippet widgets/elidedlabel/elidedlabel.h 0 - - The \c isElided property depends the font, text content and geometry of the - widget. Whenever any of these change, the \c elisionChanged() signal might - trigger. We cache the current elision value in \c elided, so that it - doesn't have to be recomputed every time it's asked for. - - - \section1 ElidedLabel Class Implementation - - Except for initializing the member variables, the constructor sets the size - policy to be horizontally expanding, since it's meant to fill the width of - its container and grow vertically. - - \snippet widgets/elidedlabel/elidedlabel.cpp 0 - - Changing the \c content require a repaint of the widget. - - \snippet widgets/elidedlabel/elidedlabel.cpp 1 - - QTextLayout is used in the \c paintEvent() to divide the \c content into - lines, that wrap on word boundaries. Each line, except the last visible - one, is drawn \c lineSpacing pixels below the previous one. The \c draw() - method of QTextLine will draw the line using the coordinate point as the - top left corner. - - \snippet widgets/elidedlabel/elidedlabel.cpp 2 - - Unfortunately, QTextLayout does not elide text, so the last visible line - has to be treated differently. This last line is elided if it is too wide. - The \c drawText() method of QPainter draws the text starting from the base - line, which is \c ascecnt() pixels below the last drawn line. - - Finally, one more line is created to see if everything fit on this line. - - \snippet widgets/elidedlabel/elidedlabel.cpp 3 - - If the text was elided and wasn't before or vice versa, cache it in - \c elided and emit the change. - - \snippet widgets/elidedlabel/elidedlabel.cpp 4 - - - \section1 TestWidget Class Definition - - \c TestWidget is a QWidget and is the main window of the example. It - contains an \c ElidedLabel which can be resized with two QSlider widgets. - - \snippet widgets/elidedlabel/testwidget.h 0 - - \section1 TestWidget Class Implementation - - The constructor initializes the whole widget. Strings of different length - are stored in \c textSamples. The user is able to switch between these. - - \snippet widgets/elidedlabel/testwidget.cpp 0 - - An \c ElidedLabel is created to contain the first of the sample strings. - The frame is made visible to make it easier to see the actual size of the - widget. - - \snippet widgets/elidedlabel/testwidget.cpp 1 - - The buttons and the elision label are created. By connecting the - \c elisionChanged() signal to the \c setVisible() slot of the \c label, - it will act as an indicator to when the text is elided or not. This signal - could, for instance, be used to make a "More" button visible, or similar. - - \snippet widgets/elidedlabel/testwidget.cpp 2 - - The \c widthSlider and \c heightSlider specify the size of the - \c elidedText. Since the y-axis is inverted, the \c heightSlider has to be - inverted to act appropriately. - - \snippet widgets/elidedlabel/testwidget.cpp 3 - - The components are all stored in a QGridLayout, which is made the layout of - the \c TestWidget. - - \snippet widgets/elidedlabel/testwidget.cpp 4 - - The \c widthSlider and \c heightSlider have the exact same length as the - dimensions of the \c elidedText. The maximum value for both of them is - thus their lengths, and each tick indicates one pixel. - - \snippet widgets/elidedlabel/testwidget.cpp 6 - - The \c switchText() slot simply cycles through all the available sample - texts. - - \snippet widgets/elidedlabel/testwidget.cpp 7 - - These slots set the width and height of the \c elided text, in response to - changes in the sliders. - - \section1 The \c main() Function - - The \c main() function creates an instance of \c TestWidget fullscreen and - enters the message loop. - - \snippet widgets/elidedlabel/main.cpp 0 -*/ - diff --git a/examples/widgets/doc/src/embeddeddialogs.qdoc b/examples/widgets/doc/src/embeddeddialogs.qdoc index 0b31e01e0c..09df334c77 100644 --- a/examples/widgets/doc/src/embeddeddialogs.qdoc +++ b/examples/widgets/doc/src/embeddeddialogs.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example graphicsview/embeddeddialogs diff --git a/examples/widgets/doc/src/extension.qdoc b/examples/widgets/doc/src/extension.qdoc deleted file mode 100644 index c895258acf..0000000000 --- a/examples/widgets/doc/src/extension.qdoc +++ /dev/null @@ -1,145 +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 dialogs/extension - \title Extension Example - \ingroup examples-dialogs - - \brief The Extension example shows how to add an extension to a QDialog - using the QAbstractButton::toggled() signal and the - QWidget::setVisible() slot. - - \image extension-example.png Screenshot of the Extension example - - The Extension application lets the user add search parameters in - a dialog and launch a simple or advanced search. - - The simple search has two options: \uicontrol {Match case} and \uicontrol - {Search from start}. The advanced search offers search for \uicontrol {Whole words}, - \uicontrol {Search backward}, and \uicontrol {Search selection}. The - application starts with simple search as the default. Click the \uicontrol More button - to show the advanced search options: - - \image extension_more.png Screenshot of the Extension example - - \section1 FindDialog Class Definition - - The \c FindDialog class inherits QDialog. QDialog is the - base class for dialog windows. A dialog window is a top-level - window mostly used for short-term tasks and brief communications - with the user. - - \snippet dialogs/extension/finddialog.h 0 - - The \c FindDialog widget is the main application widget, and - displays the application's search options and controlling - buttons. - - In addition to the constructor, there are several child widgets: - - \list - \li A QLineEdit with an associated QLabel to let the - user type a word to search for. - \li Several \l {QCheckBox}{QCheckBox}es to facilitate the search options. - \li Three \l {QPushButton}{QPushButton}s: - \list - \li the \uicontrol Find button to start a search - \li the \uicontrol More button to enable an advanced search - \li a QWidget representing the application's extension part - \endlist - \endlist - - \section1 FindDialog Class Implementation - - Create the standard child widgets for the simple search in the constructor: - the QLineEdit with the associated QLabel, two {QCheckBox}es and all the - \l {QPushButton}{QPushButton}s. - - \snippet dialogs/extension/finddialog.cpp 0 - - This snippet illustrates how you can define a shortcut key - for a widget. A shortcut should be defined by putting the ampersand - character (\c &) in front of the letter that should - become the shortcut. - For example, for \uicontrol {Find what}, pressing \uicontrol Alt - and \uicontrol w transfers focus to the QLineEdit widget. - Shortcuts can also be used for checking on or off a checkmark. - For example, pressing \uicontrol Alt and \uicontrol c puts the check mark - on \uicontrol {Match Case} if it was unchecked and vice versa. - It is the QLabel::setBuddy() method that links a widget to the shortcut - character if it has been defined. - - Set the \uicontrol Find button's default property to true, using the - QPushButton::setDefault() function. Then the push button will be - pressed if the user presses the Enter (or Return) key. Note that a - QDialog can only have one default button. - - \snippet dialogs/extension/finddialog.cpp 2 - - Create the extension widget, and the \l {QCheckBox}{QCheckBox}es associated - with the advanced search options. - - \snippet dialogs/extension/finddialog.cpp 3 - - Now that the extension widget is created, connect the \uicontrol - More button's \l{QAbstractButton::toggled()}{toggled()} signal to - the extension widget's \l{QWidget::setVisible()}{setVisible()} slot. - - The QAbstractButton::toggled() signal is emitted whenever a - checkable button changes its state. The signal's argument is true - if the button is checked, or false if the button is unchecked. The - QWidget::setVisible() slot sets the widget's visible status. If - the status is true the widget is shown, otherwise the widget is - hidden. - - Since the \uicontrol More button is checkable, the connection makes - sure that the extension widget is shown depending on the state of - the \uicontrol More button. - - Create checkboxes associated with the advanced search options in - a layout installed on the extension widget. - - \snippet dialogs/extension/finddialog.cpp 4 - - Before creating the main layout, create several child layouts - for the widgets. First align the QLabel and its buddy, the - QLineEdit, using a QHBoxLayout. Then align the QLabel and the QLineEdit - vertically with the checkboxes associated with the simple search, - using a QVBoxLayout. Create also a QVBoxLayout for the buttons. - Finally, lay out the two latter layouts and the extension widget - using a QGridLayout. - - \snippet dialogs/extension/finddialog.cpp 5 - - Hide the extension widget using the QWidget::hide() - function, making the application only show the simple search - options when it starts. When the user wants to access the advanced - search options, the dialog only needs to change the visibility of - the extension widget. Qt's layout management takes care of the - dialog's appearance. -*/ diff --git a/examples/widgets/doc/src/fademessage.qdoc b/examples/widgets/doc/src/fademessage.qdoc index 2035922067..bd46593ad3 100644 --- a/examples/widgets/doc/src/fademessage.qdoc +++ b/examples/widgets/doc/src/fademessage.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example effects/fademessage diff --git a/examples/widgets/doc/src/fetchmore.qdoc b/examples/widgets/doc/src/fetchmore.qdoc index 940a252319..1e80e803d5 100644 --- a/examples/widgets/doc/src/fetchmore.qdoc +++ b/examples/widgets/doc/src/fetchmore.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example itemviews/fetchmore diff --git a/examples/widgets/doc/src/findfiles.qdoc b/examples/widgets/doc/src/findfiles.qdoc deleted file mode 100644 index d7428e7d16..0000000000 --- a/examples/widgets/doc/src/findfiles.qdoc +++ /dev/null @@ -1,293 +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 dialogs/findfiles - \title Find Files Example - \ingroup examples-dialogs - - \brief A dialog for finding files in a specified folder. - - The Find Files application allows the user to search for files in a - specified directory, matching a given file name or wildcard, - and containing a specified string (if filled in). The search - result is displayed in a table containing the names of the files - and their sizes. The application also shows the number of files found. - - The Find Files example illustrates the use of several classes: - - \table - \row - \li QProgressDialog - \li Provide feedback on the progress of a search operation - \row - \li QFileDialog - \li Browse through a file list - \row - \li QTextStream - \li Use stream operators to read a file - \row - \li QTableWidget - \li Browse through the search results in a table - \row - \li QDesktopServices - \li Open files in the result list in a suitable application - \endtable - - \image findfiles-example.png Screenshot of the Find Files example - - - \section1 Window Class Definition - - The \c Window class inherits QWidget, and is the main application - widget. It shows the search options and displays the search - results. - - \snippet dialogs/findfiles/window.h 0 - - The application has two private slots: - \table - \row - \li The \c browse() slot - \li Called whenever the user wants to browse for a directory to search in - \row - \li The \c find() slot - \li Called whenever the user launches a search with the \uicontrol Find button - \endtable - - In addition we declare several private functions: - - \table - \row - \li findFiles() - \li Search for files matching the search parameters - \row - \li showFiles() - \li Display the search result - \row - \li ceateButton() - \li Construct the widget - \row - \li createComboBox() - \li Construct the widget - \row - \li createFilesTable() - \li Construct the widget - \endtable - - \section1 Window Class Implementation - - In the constructor we first create the application's widgets. - - \snippet dialogs/findfiles/window.cpp 0 - - We create the widgets to build up the UI, and we add them to a main layout - using QGridLayout. We have, however, put the \c Find and \c Quit buttons - and a stretchable space in a separate \l QHBoxLayout first, to make the - buttons appear in the \c Window widget's bottom right corner. - - Alternatively, we could have used Qt Designer to construct a UI file, - and \l {uic} to generate this code. - - \snippet dialogs/findfiles/window.cpp 1 - - We did not create a \l QMenuBar with a \uicontrol Quit menu item; but we - would still like to have a keyboard shortcut for quitting. Since we - construct a \l QShortcut with \l QKeySequence::Quit, and connect it to - \l QApplication::quit(), on most platforms it will be possible to press - Control-Q to quit (or whichever standard Quit key is configured on that platform). - (On \macos, this is redundant, because every application gets a - \uicontrol Quit menu item automatically; but it helps to make the application portable.) - - \snippet dialogs/findfiles/window.cpp 2 - - The \c browse() slot presents a file dialog to the user, using the - QFileDialog class. QFileDialog enables a user to traverse the file - system in order to select one or many files or a directory. The - easiest way to create a QFileDialog is to use the convenience - static functions. - - Here we use the static QFileDialog::getExistingDirectory() - function which returns an existing directory selected by the - user. Then we display the directory in the directory combobox - using the QComboBox::addItem() function and update the current - index. - - QComboBox::addItem() adds an item to the combobox with the given - text (if not already present in the list), and containing - the specified userData. The item is appended to the list of - existing items. - - \snippet dialogs/findfiles/window.cpp 3 - - The \c find() slot is called whenever the user requests a new - search by pressing the \uicontrol Find button. - - First we eliminate any previous search results by setting the - table widgets row count to zero. Then we retrieve the - specified file name, text, and directory path from the respective - comboboxes. - - \snippet dialogs/findfiles/window.cpp 4 - - We use the directory's path to create a QDir; the QDir class - provides access to the directory structure and its contents. - - We use QDirIterator to iterate over the files that match the - specified file name and build a QStringList of paths. - - Then we search through all the files in the list, using the private - \c findFiles() function, eliminating the ones that don't contain the - specified text. We sort them (because QDirIterator did not). And finally, - we display the results using the private \c showFiles() function. - - If the user didn't specify any text, there is no reason to search - through the files, so we sort and display the results immediately. - - \image findfiles_progress_dialog.png Screenshot of the Progress Dialog - - \snippet dialogs/findfiles/window.cpp 5 - - In the private \c findFiles() function we search through a list of - files, looking for the ones that contain a specified text. This - can be a very slow operation depending on the number of files as - well as their sizes. QProgressDialog displays a progress dialog - if the application has to search through a large number of files, - or if some of the files have a large size. QProgressDialog can - also allow the user to abort the operation if it takes too much - time. - - \snippet dialogs/findfiles/window.cpp 6 - - We run through the files, one at a time, and for each file we - update the QProgressDialog value. This property holds the current - amount of progress made. We also update the progress dialog's - label. - - Then we call the QCoreApplication::processEvents() function using - the QApplication object. In this way we interleave the display of - the progress made with the process of searching through the files - so the application doesn't appear to be frozen. - - The QApplication class manages the GUI application's control flow - and main settings. It contains the main event loop, where all - events from the window system and other sources are processed and - dispatched. QApplication inherits QCoreApplication. The - QCoreApplication::processEvents() function processes all pending - events according to the specified QEventLoop::ProcessEventFlags - until there are no more events to process. The default flags are - QEventLoop::AllEvents. - - \snippet dialogs/findfiles/window.cpp 7 - - After updating the QProgressDialog, we open the file in read-only - mode, and read one line at a time using QTextStream. - - The QTextStream class provides a convenient interface for reading - and writing text. Using QTextStream's streaming operators, you can - conveniently read and write words, lines and numbers. - - For each line we read we check if the QProgressDialog has been - canceled. If it has, we abort the operation, otherwise we check if - the line contains the specified text. When we find the text within - one of the files, we add the file's name to a list of found files - that contain the specified text, and start searching a new file. - - Finally, we return the list of the files found. - - \snippet dialogs/findfiles/window.cpp 8 - - Both the \c findFiles() and \c showFiles() functions are called from - the \c find() slot. In the \c showFiles() function we run through - the provided list of file names, adding each relative file name to the - first column in the table widget and retrieving the file's size using - QFileInfo for the second column. We use \l QLocale::formattedDataSize() - to format the file size in a human-readable form. For later use, we set - the absolute path as a data on the QTableWidget using the - the role absoluteFileNameRole defined to be Qt::UserRole + 1. - - \snippet dialogs/findfiles/window.cpp 17 - - This allows for retrieving the name of an item using a - convenience function: - - \snippet dialogs/findfiles/window.cpp 18 - - We also update the total number of files found. - - \snippet dialogs/findfiles/window.cpp 10 - - The private \c createComboBox() function is also called from the - contructor. We create a QComboBox with the given text, and make it - editable. - - When the user enters a new string in an editable combobox, the - widget may or may not insert it, and it can insert it in several - locations, depending on the QComboBox::InsertPolicy. The default - policy is is QComboBox::InsertAtBottom. - - Then we add the provided text to the combobox, and specify the - widget's size policies, before we return a pointer to the - combobox. - - \snippet dialogs/findfiles/window.cpp 11 - - The private \c createFilesTable() function is called from the - constructor. In this function we create the QTableWidget that - will display the search results. We set its horizontal headers and - their resize mode. - - QTableWidget inherits QTableView which provides a default - model/view implementation of a table view. The - QTableView::horizontalHeader() function returns the table view's - horizontal header as a QHeaderView. The QHeaderView class provides - a header row or header column for item views, and the - QHeaderView::setResizeMode() function sets the constraints on how - the section in the header can be resized. - - Finally, we hide the QTableWidget's vertical headers using the - QWidget::hide() function, and remove the default grid drawn for - the table using the QTableView::setShowGrid() function. - - \snippet dialogs/findfiles/window.cpp 12 - - \snippet dialogs/findfiles/window.cpp 14 - - The \c openFileOfItem() slot is invoked when the user double - clicks on a cell in the table. The QDesktopServices::openUrl() - knows how to open a file given the file name. - - \snippet dialogs/findfiles/window.cpp 15 - \snippet dialogs/findfiles/window.cpp 16 - - We set the context menu policy to of the table view to Qt::CustomContextMenu - and connect a slot contextMenu() to its signal - customContextMenuRequested(). We retrieve the absolute file name - from the data of the QTableWidgetItem and populate the context menu - with actions offering to copy the file name and to open the file. -*/ - diff --git a/examples/widgets/doc/src/flowlayout.qdoc b/examples/widgets/doc/src/flowlayout.qdoc index c907cb3af7..5a3316b6e4 100644 --- a/examples/widgets/doc/src/flowlayout.qdoc +++ b/examples/widgets/doc/src/flowlayout.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example layouts/flowlayout diff --git a/examples/widgets/doc/src/fontsampler.qdoc b/examples/widgets/doc/src/fontsampler.qdoc index 2e206c7769..3b014b5713 100644 --- a/examples/widgets/doc/src/fontsampler.qdoc +++ b/examples/widgets/doc/src/fontsampler.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example painting/fontsampler diff --git a/examples/widgets/doc/src/fridgemagnets.qdoc b/examples/widgets/doc/src/fridgemagnets.qdoc index 101d0fd390..149cfe1351 100644 --- a/examples/widgets/doc/src/fridgemagnets.qdoc +++ b/examples/widgets/doc/src/fridgemagnets.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example draganddrop/fridgemagnets @@ -91,7 +67,7 @@ constructor, or by using the \l{QPainter::}{begin()} method as we do in this example. The \l{QPainter::}{end()} method deactivates it. Note that the latter function is called automatically upon - destruction when the painter is actived by its constructor. The + destruction when the painter is activated by its constructor. The QPainter::Antialiasing render hint ensures that the paint engine will antialias the edges of primitives if possible. @@ -249,7 +225,7 @@ \section2 Dropping - When a a drag and drop action enters our widget, we will receive a + When a drag and drop action enters our widget, we will receive a drag enter \e event. QDragEnterEvent inherits most of its functionality from QDragMoveEvent, which in turn inherits most of its functionality from QDropEvent. Note that we must accept this diff --git a/examples/widgets/doc/src/frozencolumn.qdoc b/examples/widgets/doc/src/frozencolumn.qdoc index 705d190582..54040bc9e1 100644 --- a/examples/widgets/doc/src/frozencolumn.qdoc +++ b/examples/widgets/doc/src/frozencolumn.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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 |