Convert Group Box Example to snippets and screenshots
Remove the Group Box Example from the repository, eliminating the associated example codes, screenshot, and documentation file. The only relevant portion used in the QGroupBox class has been relocated to the existing snippet file. Additionally, all references to this example across other files have been removed. Fixes: QTBUG-119980 Pick-to: 6.7 6.6 Change-Id: I66f9dd9dab1fe64f2d20424af3acd135201827d2 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
2d2fae4863
commit
f371f8a64d
Binary file not shown.
Before Width: | Height: | Size: 9.5 KiB |
@ -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
|
||||
*/
|
@ -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)
|
||||
|
@ -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})
|
@ -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
|
@ -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();
|
||||
}
|
@ -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]
|
@ -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
|
@ -2,7 +2,6 @@ TEMPLATE = subdirs
|
||||
SUBDIRS = analogclock \
|
||||
calculator \
|
||||
calendarwidget \
|
||||
groupbox \
|
||||
lineedits \
|
||||
scribble \
|
||||
shapedclock \
|
||||
|
@ -4,3 +4,20 @@
|
||||
//! [0]
|
||||
g->setTitle("&User information");
|
||||
//! [0]
|
||||
|
||||
//! [Set up QGroupBox with layout]
|
||||
QGroupBox *groupBox = new QGroupBox(tr("Group Box with Layout"));
|
||||
|
||||
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);
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(radio1);
|
||||
vbox->addWidget(radio2);
|
||||
vbox->addWidget(radio3);
|
||||
vbox->addStretch(1);
|
||||
groupBox->setLayout(vbox);
|
||||
//! [Set up QGroupBox with layout]
|
||||
|
@ -133,9 +133,9 @@ void QGroupBoxPrivate::click()
|
||||
widgets). The following example shows how we can set up a
|
||||
QGroupBox with a layout:
|
||||
|
||||
\snippet widgets/groupbox/window.cpp 2
|
||||
\snippet code/src_gui_widgets_qgroupbox.cpp Set up QGroupBox with layout
|
||||
|
||||
\sa QButtonGroup, {Group Box Example}
|
||||
\sa QButtonGroup
|
||||
*/
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ void QRadioButtonPrivate::init()
|
||||
setDown(), isDown(), autoRepeat(), group(), setAutoRepeat(),
|
||||
toggle(), pressed(), released(), clicked(), and toggled().
|
||||
|
||||
\sa QPushButton, QToolButton, QCheckBox, {Group Box Example}
|
||||
\sa QPushButton, QToolButton, QCheckBox
|
||||
*/
|
||||
|
||||
|
||||
|
@ -85,7 +85,6 @@
|
||||
"widgets/charactermap Example", "examples/widgets/widgets/charactermap", "charactermap", 10, -1
|
||||
"widgets/codeeditor Example", "examples/widgets/widgets/codeeditor", "codeeditor", 0, -1
|
||||
"widgets/digitalclock Example", "examples/widgets/widgets/digitalclock", "digitalclock", 10, -1
|
||||
"widgets/groupbox Example", "examples/widgets/widgets/groupbox", "groupbox", 10, -1
|
||||
"widgets/icons Example", "examples/widgets/widgets/icons", "icons", 10, -1
|
||||
"widgets/imageviewer Example", "examples/widgets/widgets/imageviewer", "imageviewer", 10, -1
|
||||
"widgets/lineedits Example", "examples/widgets/widgets/lineedits", "lineedits", 10, -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user