summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/ipc/CMakeLists.txt2
-rw-r--r--examples/corelib/platform/androidnotifier/androidnotifier.pro3
-rw-r--r--examples/corelib/platform/androidnotifier/main.cpp4
-rw-r--r--examples/gui/doc/src/rhiwindow.qdoc5
-rw-r--r--examples/gui/rhiwindow/rhiwindow.cpp9
-rw-r--r--examples/widgets/doc/src/coloreditorfactory.qdoc132
-rw-r--r--examples/widgets/doc/src/groupbox.qdoc117
-rw-r--r--examples/widgets/itemviews/CMakeLists.txt1
-rw-r--r--examples/widgets/itemviews/addressbook/addresswidget.cpp5
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt39
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro12
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp39
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h32
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/main.cpp16
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/window.cpp55
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/window.h20
-rw-r--r--examples/widgets/itemviews/itemviews.pro1
-rw-r--r--examples/widgets/widgets/CMakeLists.txt1
-rw-r--r--examples/widgets/widgets/groupbox/CMakeLists.txt38
-rw-r--r--examples/widgets/widgets/groupbox/groupbox.pro9
-rw-r--r--examples/widgets/widgets/groupbox/main.cpp14
-rw-r--r--examples/widgets/widgets/groupbox/window.cpp155
-rw-r--r--examples/widgets/widgets/groupbox/window.h29
-rw-r--r--examples/widgets/widgets/widgets.pro1
24 files changed, 18 insertions, 721 deletions
diff --git a/examples/corelib/ipc/CMakeLists.txt b/examples/corelib/ipc/CMakeLists.txt
index 420acfc83a..270f71faec 100644
--- a/examples/corelib/ipc/CMakeLists.txt
+++ b/examples/corelib/ipc/CMakeLists.txt
@@ -4,7 +4,7 @@
if(NOT TARGET Qt6::Widgets)
return()
endif()
-if(QT_FEATURE_sharedmemory)
+if(QT_FEATURE_sharedmemory AND QT_FEATURE_systemsemaphore)
qt_internal_add_example(sharedmemory)
endif()
if(QT_FEATURE_localserver AND TARGET Qt6::Network)
diff --git a/examples/corelib/platform/androidnotifier/androidnotifier.pro b/examples/corelib/platform/androidnotifier/androidnotifier.pro
index 6ac4c69eb3..7e5b845e10 100644
--- a/examples/corelib/platform/androidnotifier/androidnotifier.pro
+++ b/examples/corelib/platform/androidnotifier/androidnotifier.pro
@@ -1,5 +1,4 @@
-QT += core gui
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+QT += core gui widgets
QT += core-private # For Notification permission request
SOURCES += \
diff --git a/examples/corelib/platform/androidnotifier/main.cpp b/examples/corelib/platform/androidnotifier/main.cpp
index 33e77c7018..07eff5d2b0 100644
--- a/examples/corelib/platform/androidnotifier/main.cpp
+++ b/examples/corelib/platform/androidnotifier/main.cpp
@@ -41,11 +41,11 @@ int main(int argc, char *argv[])
widget.setLayout(&mainLayout);
//! [Connect button signals]
- QObject::connect(&happyButton, &QPushButton::clicked, []() {
+ QObject::connect(&happyButton, &QPushButton::clicked, &happyButton, []() {
NotificationClient().setNotification("The user is happy!");
});
- QObject::connect(&sadButton, &QPushButton::clicked, []() {
+ QObject::connect(&sadButton, &QPushButton::clicked, &happyButton, []() {
NotificationClient().setNotification("The user is sad!");
});
//! [Connect button signals]
diff --git a/examples/gui/doc/src/rhiwindow.qdoc b/examples/gui/doc/src/rhiwindow.qdoc
index b6fc279816..3ee33c8002 100644
--- a/examples/gui/doc/src/rhiwindow.qdoc
+++ b/examples/gui/doc/src/rhiwindow.qdoc
@@ -427,6 +427,11 @@
QRhiShaderResourceBindings, continue to be valid all the time. It is only
the underlying native resources that come and go over time.
+ Note also that we set a device pixel ratio on the image that matches
+ the window that we're drawing into. This ensures that the drawing code
+ can be DPR-agnostic, producing the same layout regardless of the DPR,
+ while also taking advantage of the additional pixels for improved fidelity.
+
\snippet rhiwindow/rhiwindow.cpp ensure-texture
Once a QImage is generated and the QPainter-based drawing into it has
diff --git a/examples/gui/rhiwindow/rhiwindow.cpp b/examples/gui/rhiwindow/rhiwindow.cpp
index 345286b635..3ae6faa802 100644
--- a/examples/gui/rhiwindow/rhiwindow.cpp
+++ b/examples/gui/rhiwindow/rhiwindow.cpp
@@ -281,17 +281,18 @@ void HelloWindow::ensureFullscreenTexture(const QSize &pixelSize, QRhiResourceUp
m_texture->create();
QImage image(pixelSize, QImage::Format_RGBA8888_Premultiplied);
+ image.setDevicePixelRatio(devicePixelRatio());
//! [ensure-texture]
QPainter painter(&image);
- painter.fillRect(QRectF(QPointF(0, 0), pixelSize), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f));
+ painter.fillRect(QRectF(QPointF(0, 0), size()), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f));
painter.setPen(Qt::transparent);
painter.setBrush({ QGradient(QGradient::DeepBlue) });
- painter.drawRoundedRect(QRectF(QPointF(20, 20), pixelSize - QSize(40, 40)), 16, 16);
+ painter.drawRoundedRect(QRectF(QPointF(20, 20), size() - QSize(40, 40)), 16, 16);
painter.setPen(Qt::black);
QFont font;
- font.setPixelSize(0.05 * qMin(pixelSize.width(), pixelSize.height()));
+ font.setPixelSize(0.05 * qMin(width(), height()));
painter.setFont(font);
- painter.drawText(QRectF(QPointF(60, 60), pixelSize - QSize(120, 120)), 0,
+ painter.drawText(QRectF(QPointF(60, 60), size() - QSize(120, 120)), 0,
QLatin1String("Rendering with QRhi to a resizable QWindow.\nThe 3D API is %1.\nUse the command-line options to choose a different API.")
.arg(graphicsApiName()));
painter.end();
diff --git a/examples/widgets/doc/src/coloreditorfactory.qdoc b/examples/widgets/doc/src/coloreditorfactory.qdoc
deleted file mode 100644
index f43a7eb95c..0000000000
--- a/examples/widgets/doc/src/coloreditorfactory.qdoc
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/coloreditorfactory
- \title Color Editor Factory Example
- \examplecategory {User Interface Components}
- \ingroup examples-itemviews
- \brief This example shows how to create an editor that can be used by
- a QStyledItemDelegate.
-
- \image coloreditorfactoryimage.png
-
- When editing data in a QListView, QTableView, or QTreeView,
- editors are created and displayed by a \l{Delegate
- Classes}{delegate}. QStyledItemDelegate, which is the default delegate
- used by Qt's \l{View Classes}{item views}, uses a
- QItemEditorFactory to create editors for it. A unique instance
- provided by QItemEditorFactory is by default installed on all
- item delegates.
-
- An item editor factory contains a collection of
- QItemEditorCreatorBase instances, which are specialized factories
- that produce editors for one particular QVariant data type (all
- models in Qt store their data in \l{QVariant}s). An editor can be any
- Qt or custom widget.
-
- In this example, we will create an editor (implemented in the \c
- ColorListEditor class) that can edit the QColor data type and be
- used by \l{QStyledItemDelegate}s. We do this by creating a new
- QItemEditorCreatorBase that produces \c ColorListEditors and
- register it with a new factory, which we set as the default editor
- item factory (the unique factory instance). To test our editor, we
- have implemented the \c Window class, which displays a
- QTableWidget in which \l{QColor}s can be edited.
-
- \section1 Window Class Implementation
-
- In the Window class, we create the item editor creator
- base for our color editor and add it to the default factory.
- We also create a QTableWidget in which our editor can be
- tested. It is filled with some data and displayed in a window.
-
- We take a closer look at the constructor:
-
- \snippet itemviews/coloreditorfactory/window.cpp 0
-
- The QStandardItemEditorCreator is a convenience class that
- inherits QItemEditorCreatorBase. Its constructor takes a template
- class, of which instances are returned from
- \l{QItemEditorCreatorBase::}{createWidget()}. The creator uses a
- constructor that takes a QWidget as its only parameter; the
- template class must provide this. This way, there is no need to
- subclass QStandardItemEditorCreator.
-
- After the new factory has been set, all standard item delegates
- will use it (i.e, also delegates that were created before the new
- default factory was set).
-
- The \c createGUI() function sets up the table and fills it
- with data.
-
- \section1 ColorListEditor Definition
-
- The ColorListEditor inherits QComboBox and lets the user
- select a QColor from its popup list.
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.h 0
-
- QStyledItemDelegate manages the interaction between the editor and
- the model, i.e., it retrieves data to edit from the model and
- store data from the editor in the model. The data that is edited
- by an editor is stored in the editor's user data property, and the
- delegate uses Qt's \l{Qt's Property System}{property system} to
- access it by name. We declare our user data property with the
- Q_PROPERTY macro. The property is set to be the user type with the
- USER keyword.
-
- \section1 ColorListEditor Implementation
-
- The constructor of \c ColorListEditor simply calls \c
- populateList(), which we will look at later. We move on to the
- \c color() function:
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.cpp 0
-
- We return the data that is selected in the combobox. The data
- is stored in the Qt::DecorationRole as the color is then also
- displayed in the popup list (as shown in the image above).
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.cpp 1
-
- The \c findData() function searches the items in the combobox
- and returns the index of the item that has \c color in the
- Qt::Decoration role.
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.cpp 2
-
- Qt knows some predefined colors by name. We simply loop
- through these to fill our editor with items.
-
- \section1 Further Customization of Item View Editors
-
- You can customize Qt's \l{Model/View Programming}{model view
- framework} in many ways. The procedure shown in this example is
- usually sufficient to provide custom editors. Further
- customization is achieved by subclassing QItemEditorFactory
- and QItemEditorCreatorBase. It is also possible to subclass
- QStyledItemDelegate if you don't wish to use a factory at all.
-
- Possible suggestions are:
-
- \list
- \li If the editor widget has no user property defined, the delegate
- asks the factory for the property name, which it in turn
- asks the item editor creator for. In this case, you can use
- the QItemEditorCreator class, which takes the property
- name to use for editing as a constructor argument.
- \li If the editor requires other constructors or other
- initialization than provided by QItemEditorCreatorBase, you
- must reimplement
- QItemEditorCreatorBase::createWidget().
- \li You could also subclass QItemEditorFactory if you only want
- to provide editors for certain kinds of data or use another
- method of creating the editors than using creator bases.
- \endlist
-
- In this example, we use a standard QVariant data type. You can
- also use custom types. In the \l{Star Delegate Example}, we
- show how to store a custom data type in a QVariant and paint
- and edit it in a class that inherits QStyledItemDelegate.
-*/
diff --git a/examples/widgets/doc/src/groupbox.qdoc b/examples/widgets/doc/src/groupbox.qdoc
deleted file mode 100644
index aa339098ab..0000000000
--- a/examples/widgets/doc/src/groupbox.qdoc
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/groupbox
- \title Group Box Example
- \examplecategory {User Interface Components}
- \ingroup examples-widgets
- \brief The Group Box example shows how to use the different kinds of group
- boxes in Qt.
-
- Group boxes are container widgets that organize buttons into groups,
- both logically and on screen. They manage the interactions between
- the user and the application so that you do not have to enforce
- simple constraints.
-
- Group boxes are usually used to organize check boxes and radio
- buttons into exclusive groups.
-
- \borderedimage groupbox-example.png
-
- The Group Boxes example consists of a single \c Window class that
- is used to show four group boxes: an exclusive radio button group,
- a non-exclusive checkbox group, an exclusive radio button group
- with an enabling checkbox, and a group box with normal push buttons.
-
- \section1 Window Class Definition
-
- The \c Window class is a subclass of \c QWidget that is used to
- display a number of group boxes. The class definition contains
- functions to construct each group box and populate it with different
- selections of button widgets:
-
- \snippet widgets/groupbox/window.h 0
-
- In the example, the widget will be used as a top-level window, so
- the constructor is defined so that we do not have to specify a parent
- widget.
-
- \section1 Window Class Implementation
-
- The constructor creates a grid layout and fills it with each of the
- group boxes that are to be displayed:
-
- \snippet widgets/groupbox/window.cpp 0
-
- The functions used to create each group box each return a
- QGroupBox to be inserted into the grid layout.
-
- \snippet widgets/groupbox/window.cpp 1
-
- The first group box contains and manages three radio buttons. Since
- the group box contains only radio buttons, it is exclusive by
- default, so only one radio button can be checked at any given time.
- We check the first radio button to ensure that the button group
- contains one checked button.
-
- \snippet widgets/groupbox/window.cpp 3
-
- We use a vertical layout within the group box to present the
- buttons in the form of a vertical list, and return the group
- box to the constructor.
-
- The second group box is itself checkable, providing a convenient
- way to disable all the buttons inside it. Initially, it is
- unchecked, so the group box itself must be checked before any of
- the radio buttons inside can be checked.
-
- \snippet widgets/groupbox/window.cpp 4
-
- The group box contains three exclusive radio buttons, and an
- independent checkbox. For consistency, one radio button must be
- checked at all times, so we ensure that the first one is initially
- checked.
-
- \snippet widgets/groupbox/window.cpp 5
-
- The buttons are arranged in the same way as those in the first
- group box.
-
- \snippet widgets/groupbox/window.cpp 6
-
- The third group box is constructed with a "flat" style that is
- better suited to certain types of dialog.
-
- \snippet widgets/groupbox/window.cpp 7
-
- This group box contains only checkboxes, so it is non-exclusive by
- default. This means that each checkbox can be checked independently
- of the others.
-
- \snippet widgets/groupbox/window.cpp 8
-
- Again, we use a vertical layout within the group box to present
- the buttons in the form of a vertical list.
-
- \snippet widgets/groupbox/window.cpp 9
-
- The final group box contains only push buttons and, like the
- second group box, it is checkable.
-
- \snippet widgets/groupbox/window.cpp 10
-
- We create a normal button, a toggle button, and a flat push button:
-
- \snippet widgets/groupbox/window.cpp 11
-
- Push buttons can be used to display popup menus. We create one, and
- attach a simple menu to it:
-
- \snippet widgets/groupbox/window.cpp 12
-
- Finally, we lay out the widgets vertically, and return the group box
- that we created:
-
- \snippet widgets/groupbox/window.cpp 13
-*/
diff --git a/examples/widgets/itemviews/CMakeLists.txt b/examples/widgets/itemviews/CMakeLists.txt
index 0c2912178f..e80d90160b 100644
--- a/examples/widgets/itemviews/CMakeLists.txt
+++ b/examples/widgets/itemviews/CMakeLists.txt
@@ -3,7 +3,6 @@
qt_internal_add_example(addressbook)
qt_internal_add_example(basicsortfiltermodel)
-qt_internal_add_example(coloreditorfactory)
qt_internal_add_example(combowidgetmapper)
qt_internal_add_example(customsortfiltermodel)
qt_internal_add_example(editabletreemodel)
diff --git a/examples/widgets/itemviews/addressbook/addresswidget.cpp b/examples/widgets/itemviews/addressbook/addresswidget.cpp
index bde1cdc334..5b226793e4 100644
--- a/examples/widgets/itemviews/addressbook/addresswidget.cpp
+++ b/examples/widgets/itemviews/addressbook/addresswidget.cpp
@@ -34,7 +34,10 @@ void AddressWidget::showAddEntryDialog()
//! [3]
void AddressWidget::addEntry(const QString &name, const QString &address)
{
- if (!table->getContacts().contains({ name, address })) {
+ if (!name.front().isLetter()) {
+ QMessageBox::information(this, tr("Invalid name"),
+ tr("The name must start with a letter."));
+ } else if (!table->getContacts().contains({ name, address })) {
table->insertRows(0, 1, QModelIndex());
QModelIndex index = table->index(0, 0, QModelIndex());
diff --git a/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt b/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt
deleted file mode 100644
index 5dbc780027..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(coloreditorfactory LANGUAGES CXX)
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_standard_project_setup()
-
-qt_add_executable(coloreditorfactory
- colorlisteditor.cpp colorlisteditor.h
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(coloreditorfactory PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(coloreditorfactory PRIVATE
- Qt6::Core
- Qt6::Gui
- Qt6::Widgets
-)
-
-install(TARGETS coloreditorfactory
- BUNDLE DESTINATION .
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-)
-
-qt_generate_deploy_app_script(
- TARGET coloreditorfactory
- OUTPUT_SCRIPT deploy_script
- NO_UNSUPPORTED_PLATFORM_ERROR
-)
-install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro b/examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro
deleted file mode 100644
index 2d16ab5e2b..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = colorlisteditor.h \
- window.h
-SOURCES = colorlisteditor.cpp \
- window.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/coloreditorfactory
-INSTALLS += target
diff --git a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp b/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp
deleted file mode 100644
index 44ce168c93..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "colorlisteditor.h"
-
-#include <QtWidgets>
-
-ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget)
-{
- populateList();
-}
-
-//! [0]
-QColor ColorListEditor::color() const
-{
- return qvariant_cast<QColor>(itemData(currentIndex(), Qt::DecorationRole));
-}
-//! [0]
-
-//! [1]
-void ColorListEditor::setColor(const QColor &color)
-{
- setCurrentIndex(findData(color, Qt::DecorationRole));
-}
-//! [1]
-
-//! [2]
-void ColorListEditor::populateList()
-{
- const QStringList colorNames = QColor::colorNames();
-
- for (int i = 0; i < colorNames.size(); ++i) {
- QColor color(colorNames[i]);
-
- insertItem(i, colorNames[i]);
- setItemData(i, color, Qt::DecorationRole);
- }
-}
-//! [2]
diff --git a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h b/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h
deleted file mode 100644
index 8dfa9d9f05..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef COLORLISTEDITOR_H
-#define COLORLISTEDITOR_H
-
-#include <QComboBox>
-
-QT_BEGIN_NAMESPACE
-class QColor;
-class QWidget;
-QT_END_NAMESPACE
-
-//! [0]
-class ColorListEditor : public QComboBox
-{
- Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor USER true)
-
-public:
- ColorListEditor(QWidget *widget = nullptr);
-
-public:
- QColor color() const;
- void setColor(const QColor &color);
-
-private:
- void populateList();
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/itemviews/coloreditorfactory/main.cpp b/examples/widgets/itemviews/coloreditorfactory/main.cpp
deleted file mode 100644
index c4339e22c1..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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 argv, char **args)
-{
- QApplication app(argv, args);
-
- Window window;
- window.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/coloreditorfactory/window.cpp b/examples/widgets/itemviews/coloreditorfactory/window.cpp
deleted file mode 100644
index 31c8c1ae13..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/window.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "window.h"
-#include "colorlisteditor.h"
-
-#include <QtWidgets>
-
-//! [0]
-Window::Window()
-{
- QItemEditorFactory *factory = new QItemEditorFactory;
-
- QItemEditorCreatorBase *colorListCreator =
- new QStandardItemEditorCreator<ColorListEditor>();
-
- factory->registerEditor(QMetaType::QColor, colorListCreator);
-
- QItemEditorFactory::setDefaultFactory(factory);
-
- createGUI();
-}
-//! [0]
-
-void Window::createGUI()
-{
- const QList<QPair<QString, QColor>> list = { { tr("Alice"), QColor("aliceblue") },
- { tr("Neptun"), QColor("aquamarine") },
- { tr("Ferdinand"), QColor("springgreen") } };
-
- QTableWidget *table = new QTableWidget(3, 2);
- table->setHorizontalHeaderLabels({ tr("Name"), tr("Hair Color") });
- table->verticalHeader()->setVisible(false);
- table->resize(150, 50);
-
- for (int i = 0; i < 3; ++i) {
- const QPair<QString, QColor> &pair = list.at(i);
-
- QTableWidgetItem *nameItem = new QTableWidgetItem(pair.first);
- QTableWidgetItem *colorItem = new QTableWidgetItem;
- colorItem->setData(Qt::DisplayRole, pair.second);
-
- table->setItem(i, 0, nameItem);
- table->setItem(i, 1, colorItem);
- }
- table->resizeColumnToContents(0);
- table->horizontalHeader()->setStretchLastSection(true);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(table, 0, 0);
-
- setLayout(layout);
-
- setWindowTitle(tr("Color Editor Factory"));
-}
diff --git a/examples/widgets/itemviews/coloreditorfactory/window.h b/examples/widgets/itemviews/coloreditorfactory/window.h
deleted file mode 100644
index 4130b2d4ac..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/window.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window();
-
-private:
- void createGUI();
-};
-
-#endif
diff --git a/examples/widgets/itemviews/itemviews.pro b/examples/widgets/itemviews/itemviews.pro
index 92997782a2..db06874ba5 100644
--- a/examples/widgets/itemviews/itemviews.pro
+++ b/examples/widgets/itemviews/itemviews.pro
@@ -1,7 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = addressbook \
basicsortfiltermodel \
- coloreditorfactory \
combowidgetmapper \
customsortfiltermodel \
editabletreemodel \
diff --git a/examples/widgets/widgets/CMakeLists.txt b/examples/widgets/widgets/CMakeLists.txt
index 0dcc71d230..feb3067727 100644
--- a/examples/widgets/widgets/CMakeLists.txt
+++ b/examples/widgets/widgets/CMakeLists.txt
@@ -4,7 +4,6 @@
qt_internal_add_example(analogclock)
qt_internal_add_example(calculator)
qt_internal_add_example(calendarwidget)
-qt_internal_add_example(groupbox)
qt_internal_add_example(lineedits)
qt_internal_add_example(scribble)
qt_internal_add_example(shapedclock)
diff --git a/examples/widgets/widgets/groupbox/CMakeLists.txt b/examples/widgets/widgets/groupbox/CMakeLists.txt
deleted file mode 100644
index ab2469eaad..0000000000
--- a/examples/widgets/widgets/groupbox/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(groupbox LANGUAGES CXX)
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_standard_project_setup()
-
-qt_add_executable(groupbox
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(groupbox PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(groupbox PRIVATE
- Qt6::Core
- Qt6::Gui
- Qt6::Widgets
-)
-
-install(TARGETS groupbox
- BUNDLE DESTINATION .
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-)
-
-qt_generate_deploy_app_script(
- TARGET groupbox
- OUTPUT_SCRIPT deploy_script
- NO_UNSUPPORTED_PLATFORM_ERROR
-)
-install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/groupbox/groupbox.pro b/examples/widgets/widgets/groupbox/groupbox.pro
deleted file mode 100644
index 5fb6a14835..0000000000
--- a/examples/widgets/widgets/groupbox/groupbox.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-HEADERS = window.h
-SOURCES = window.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/groupbox
-INSTALLS += target
diff --git a/examples/widgets/widgets/groupbox/main.cpp b/examples/widgets/widgets/groupbox/main.cpp
deleted file mode 100644
index 27409403a5..0000000000
--- a/examples/widgets/widgets/groupbox/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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/widgets/groupbox/window.cpp b/examples/widgets/widgets/groupbox/window.cpp
deleted file mode 100644
index 16ea8cc94f..0000000000
--- a/examples/widgets/widgets/groupbox/window.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "window.h"
-
-#include <QCheckBox>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QMenu>
-#include <QPushButton>
-#include <QRadioButton>
-
-//! [0]
-Window::Window(QWidget *parent)
- : QWidget(parent)
-{
- QGridLayout *grid = new QGridLayout;
- grid->addWidget(createFirstExclusiveGroup(), 0, 0);
- grid->addWidget(createSecondExclusiveGroup(), 1, 0);
- grid->addWidget(createNonExclusiveGroup(), 0, 1);
- grid->addWidget(createPushButtonGroup(), 1, 1);
- setLayout(grid);
-
- setWindowTitle(tr("Group Boxes"));
- resize(480, 320);
-}
-//! [0]
-
-//! [1]
-QGroupBox *Window::createFirstExclusiveGroup()
-{
-//! [2]
- QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
-
- QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
- QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
- QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
-
- radio1->setChecked(true);
-//! [1] //! [3]
-
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(radio1);
- vbox->addWidget(radio2);
- vbox->addWidget(radio3);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-//! [2]
-
- return groupBox;
-}
-//! [3]
-
-//! [4]
-QGroupBox *Window::createSecondExclusiveGroup()
-{
- QGroupBox *groupBox = new QGroupBox(tr("E&xclusive Radio Buttons"));
- groupBox->setCheckable(true);
- groupBox->setChecked(false);
-//! [4]
-
-//! [5]
- QRadioButton *radio1 = new QRadioButton(tr("Rad&io button 1"));
- QRadioButton *radio2 = new QRadioButton(tr("Radi&o button 2"));
- QRadioButton *radio3 = new QRadioButton(tr("Radio &button 3"));
- radio1->setChecked(true);
- QCheckBox *checkBox = new QCheckBox(tr("Ind&ependent checkbox"));
- checkBox->setChecked(true);
-//! [5]
-
-//! [6]
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(radio1);
- vbox->addWidget(radio2);
- vbox->addWidget(radio3);
- vbox->addWidget(checkBox);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-
- return groupBox;
-}
-//! [6]
-
-//! [7]
-QGroupBox *Window::createNonExclusiveGroup()
-{
- QGroupBox *groupBox = new QGroupBox(tr("Non-Exclusive Checkboxes"));
- groupBox->setFlat(true);
-//! [7]
-
-//! [8]
- QCheckBox *checkBox1 = new QCheckBox(tr("&Checkbox 1"));
- QCheckBox *checkBox2 = new QCheckBox(tr("C&heckbox 2"));
- checkBox2->setChecked(true);
- QCheckBox *tristateBox = new QCheckBox(tr("Tri-&state button"));
- tristateBox->setTristate(true);
-//! [8]
- tristateBox->setCheckState(Qt::PartiallyChecked);
-
-//! [9]
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(checkBox1);
- vbox->addWidget(checkBox2);
- vbox->addWidget(tristateBox);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-
- return groupBox;
-}
-//! [9]
-
-//! [10]
-QGroupBox *Window::createPushButtonGroup()
-{
- QGroupBox *groupBox = new QGroupBox(tr("&Push Buttons"));
- groupBox->setCheckable(true);
- groupBox->setChecked(true);
-//! [10]
-
-//! [11]
- QPushButton *pushButton = new QPushButton(tr("&Normal Button"));
- QPushButton *toggleButton = new QPushButton(tr("&Toggle Button"));
- toggleButton->setCheckable(true);
- toggleButton->setChecked(true);
- QPushButton *flatButton = new QPushButton(tr("&Flat Button"));
- flatButton->setFlat(true);
-//! [11]
-
-//! [12]
- QPushButton *popupButton = new QPushButton(tr("Pop&up Button"));
- QMenu *menu = new QMenu(this);
- menu->addAction(tr("&First Item"));
- menu->addAction(tr("&Second Item"));
- menu->addAction(tr("&Third Item"));
- menu->addAction(tr("F&ourth Item"));
- popupButton->setMenu(menu);
-//! [12]
-
- QMenu *subMenu = menu->addMenu(tr("Submenu"));
- subMenu->addAction(tr("Item 1"));
- subMenu->addAction(tr("Item 2"));
- subMenu->addAction(tr("Item 3"));
-
-//! [13]
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(pushButton);
- vbox->addWidget(toggleButton);
- vbox->addWidget(flatButton);
- vbox->addWidget(popupButton);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-
- return groupBox;
-}
-//! [13]
diff --git a/examples/widgets/widgets/groupbox/window.h b/examples/widgets/widgets/groupbox/window.h
deleted file mode 100644
index 714f22b756..0000000000
--- a/examples/widgets/widgets/groupbox/window.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QGroupBox;
-QT_END_NAMESPACE
-
-//! [0]
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window(QWidget *parent = nullptr);
-
-private:
- QGroupBox *createFirstExclusiveGroup();
- QGroupBox *createSecondExclusiveGroup();
- QGroupBox *createNonExclusiveGroup();
- QGroupBox *createPushButtonGroup();
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/widgets.pro b/examples/widgets/widgets/widgets.pro
index 9fe06d4d80..5dd8f5eedc 100644
--- a/examples/widgets/widgets/widgets.pro
+++ b/examples/widgets/widgets/widgets.pro
@@ -2,7 +2,6 @@ TEMPLATE = subdirs
SUBDIRS = analogclock \
calculator \
calendarwidget \
- groupbox \
lineedits \
scribble \
shapedclock \