| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | /*!
|
|---|
| 45 | \class QButtonGroup
|
|---|
| 46 | \brief The QButtonGroup class provides a container to organize groups of
|
|---|
| 47 | button widgets.
|
|---|
| 48 |
|
|---|
| 49 | \ingroup organizers
|
|---|
| 50 | \ingroup geomanagement
|
|---|
| 51 | \ingroup appearance
|
|---|
| 52 | \mainclass
|
|---|
| 53 |
|
|---|
| 54 | QButtonGroup provides an abstract container into which button widgets can
|
|---|
| 55 | be placed. It does not provide a visual representation of this container
|
|---|
| 56 | (see QGroupBox for a container widget), but instead manages the states of
|
|---|
| 57 | each of the buttons in the group.
|
|---|
| 58 |
|
|---|
| 59 | An \l {QButtonGroup::exclusive} {exclusive} button group switches
|
|---|
| 60 | off all checkable (toggle) buttons except the one that was
|
|---|
| 61 | clicked. By default, a button group is exclusive. The buttons in a
|
|---|
| 62 | button group are usually checkable QPushButton's, \l{QCheckBox}es
|
|---|
| 63 | (normally for non-exclusive button groups), or \l{QRadioButton}s.
|
|---|
| 64 | If you create an exclusive button group, you should ensure that
|
|---|
| 65 | one of the buttons in the group is initially checked; otherwise,
|
|---|
| 66 | the group will initially be in a state where no buttons are
|
|---|
| 67 | checked.
|
|---|
| 68 |
|
|---|
| 69 | A button is added to the group with addButton(). It can be removed
|
|---|
| 70 | from the group with removeButton(). If the group is exclusive, the
|
|---|
| 71 | currently checked button is available as checkedButton(). If a
|
|---|
| 72 | button is clicked the buttonClicked() signal is emitted. For a
|
|---|
| 73 | checkable button in an exclusive group this means that the button
|
|---|
| 74 | was checked. The list of buttons in the group is returned by
|
|---|
| 75 | buttons().
|
|---|
| 76 |
|
|---|
| 77 | In addition, QButtonGroup can map between integers and buttons.
|
|---|
| 78 | You can assign an integer id to a button with setId(), and
|
|---|
| 79 | retrieve it with id(). The id of the currently checked button is
|
|---|
| 80 | available with checkedId(), and there is an overloaded signal
|
|---|
| 81 | buttonClicked() which emits the id of the button. The id \c {-1}
|
|---|
| 82 | is reserved by QButtonGroup to mean "no such button". The purpose
|
|---|
| 83 | of the mapping mechanism is to simplify the representation of enum
|
|---|
| 84 | values in a user interface.
|
|---|
| 85 |
|
|---|
| 86 | \sa QGroupBox QPushButton, QCheckBox, QRadioButton
|
|---|
| 87 | */
|
|---|
| 88 |
|
|---|
| 89 | /*!
|
|---|
| 90 | \fn QButtonGroup::QButtonGroup(QObject *parent)
|
|---|
| 91 |
|
|---|
| 92 | Constructs a new, empty button group with the given \a parent.
|
|---|
| 93 |
|
|---|
| 94 | \sa addButton() setExclusive()
|
|---|
| 95 | */
|
|---|
| 96 |
|
|---|
| 97 | /*!
|
|---|
| 98 | \fn QButtonGroup::~QButtonGroup()
|
|---|
| 99 |
|
|---|
| 100 | Destroys the button group.
|
|---|
| 101 | */
|
|---|
| 102 |
|
|---|
| 103 | /*!
|
|---|
| 104 | \property QButtonGroup::exclusive
|
|---|
| 105 | \brief whether the button group is exclusive
|
|---|
| 106 |
|
|---|
| 107 | If this property is true then only one button in the group can be checked
|
|---|
| 108 | at any given time. The user can click on any button to check it, and that
|
|---|
| 109 | button will replace the existing one as the checked button in the group.
|
|---|
| 110 |
|
|---|
| 111 | In an exclusive group, the user cannot uncheck the currently checked button
|
|---|
| 112 | by clicking on it; instead, another button in the group must be clicked
|
|---|
| 113 | to set the new checked button for that group.
|
|---|
| 114 |
|
|---|
| 115 | By default, this property is true.
|
|---|
| 116 | */
|
|---|
| 117 |
|
|---|
| 118 | /*!
|
|---|
| 119 | \fn void QButtonGroup::buttonClicked(QAbstractButton *button)
|
|---|
| 120 |
|
|---|
| 121 | This signal is emitted when the given \a button is clicked. A
|
|---|
| 122 | button is clicked when it is first pressed and then released, when
|
|---|
| 123 | its shortcut key is typed, or programmatically when
|
|---|
| 124 | QAbstractButton::click() or QAbstractButton::animateClick() is
|
|---|
| 125 | called.
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | \sa checkedButton(), QAbstractButton::clicked()
|
|---|
| 129 | */
|
|---|
| 130 |
|
|---|
| 131 | /*!
|
|---|
| 132 | \fn void QButtonGroup::buttonClicked(int id)
|
|---|
| 133 |
|
|---|
| 134 | This signal is emitted when a button with the given \a id is
|
|---|
| 135 | clicked.
|
|---|
| 136 |
|
|---|
| 137 | \sa checkedButton(), QAbstractButton::clicked()
|
|---|
| 138 | */
|
|---|
| 139 |
|
|---|
| 140 | /*!
|
|---|
| 141 | \fn void QButtonGroup::buttonPressed(QAbstractButton *button)
|
|---|
| 142 | \since 4.2
|
|---|
| 143 |
|
|---|
| 144 | This signal is emitted when the given \a button is pressed down.
|
|---|
| 145 |
|
|---|
| 146 | \sa QAbstractButton::pressed()
|
|---|
| 147 | */
|
|---|
| 148 |
|
|---|
| 149 | /*!
|
|---|
| 150 | \fn void QButtonGroup::buttonPressed(int id)
|
|---|
| 151 | \since 4.2
|
|---|
| 152 |
|
|---|
| 153 | This signal is emitted when a button with the given \a id is
|
|---|
| 154 | pressed down.
|
|---|
| 155 |
|
|---|
| 156 | \sa QAbstractButton::pressed()
|
|---|
| 157 | */
|
|---|
| 158 |
|
|---|
| 159 | /*!
|
|---|
| 160 | \fn void QButtonGroup::buttonReleased(QAbstractButton *button)
|
|---|
| 161 | \since 4.2
|
|---|
| 162 |
|
|---|
| 163 | This signal is emitted when the given \a button is released.
|
|---|
| 164 |
|
|---|
| 165 | \sa QAbstractButton::released()
|
|---|
| 166 | */
|
|---|
| 167 |
|
|---|
| 168 | /*!
|
|---|
| 169 | \fn void QButtonGroup::buttonReleased(int id)
|
|---|
| 170 | \since 4.2
|
|---|
| 171 |
|
|---|
| 172 | This signal is emitted when a button with the given \a id is
|
|---|
| 173 | released.
|
|---|
| 174 |
|
|---|
| 175 | \sa QAbstractButton::released()
|
|---|
| 176 | */
|
|---|
| 177 |
|
|---|
| 178 | /*!
|
|---|
| 179 | \fn void QButtonGroup::addButton(QAbstractButton *button, int id = -1);
|
|---|
| 180 |
|
|---|
| 181 | Adds the given \a button to the button group, with the given \a
|
|---|
| 182 | id. If \a id is -1 (the default), an id will be assigned to the
|
|---|
| 183 | button by this QButtonGroup.
|
|---|
| 184 |
|
|---|
| 185 | \sa removeButton() buttons()
|
|---|
| 186 | */
|
|---|
| 187 |
|
|---|
| 188 | /*!
|
|---|
| 189 | \fn void QButtonGroup::removeButton(QAbstractButton *button);
|
|---|
| 190 |
|
|---|
| 191 | Removes the given \a button from the button group.
|
|---|
| 192 |
|
|---|
| 193 | \sa addButton() buttons()
|
|---|
| 194 | */
|
|---|
| 195 |
|
|---|
| 196 | /*!
|
|---|
| 197 | \fn QList<QAbstractButton*> QButtonGroup::buttons() const
|
|---|
| 198 |
|
|---|
| 199 | Returns the list of this groups's buttons. This may be empty.
|
|---|
| 200 |
|
|---|
| 201 | \sa addButton(), removeButton()
|
|---|
| 202 | */
|
|---|
| 203 |
|
|---|
| 204 | /*!
|
|---|
| 205 | \fn QAbstractButton *QButtonGroup::checkedButton() const;
|
|---|
| 206 |
|
|---|
| 207 | Returns the button group's checked button, or 0 if no buttons are
|
|---|
| 208 | checked.
|
|---|
| 209 |
|
|---|
| 210 | \sa buttonClicked()
|
|---|
| 211 | */
|
|---|
| 212 |
|
|---|
| 213 | /*!
|
|---|
| 214 | \fn QAbstractButton *QButtonGroup::button(int id) const;
|
|---|
| 215 | \since 4.1
|
|---|
| 216 |
|
|---|
| 217 | Returns the button with the specified \a id, or 0 if no such button
|
|---|
| 218 | exists.
|
|---|
| 219 | */
|
|---|
| 220 |
|
|---|
| 221 | /*!
|
|---|
| 222 | \fn void QButtonGroup::setId(QAbstractButton *button, int id)
|
|---|
| 223 | \since 4.1
|
|---|
| 224 |
|
|---|
| 225 | Sets the \a id for the specified \a button. Note that \a id can
|
|---|
| 226 | not be -1.
|
|---|
| 227 |
|
|---|
| 228 | \sa id()
|
|---|
| 229 | */
|
|---|
| 230 |
|
|---|
| 231 | /*!
|
|---|
| 232 | \fn int QButtonGroup::id(QAbstractButton *button) const;
|
|---|
| 233 | \since 4.1
|
|---|
| 234 |
|
|---|
| 235 | Returns the id for the specified \a button, or -1 if no such button
|
|---|
| 236 | exists.
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 | \sa setId()
|
|---|
| 240 | */
|
|---|
| 241 |
|
|---|
| 242 | /*!
|
|---|
| 243 | \fn int QButtonGroup::checkedId() const;
|
|---|
| 244 | \since 4.1
|
|---|
| 245 |
|
|---|
| 246 | Returns the id of the checkedButton(), or -1 if no button is checked.
|
|---|
| 247 |
|
|---|
| 248 | \sa setId()
|
|---|
| 249 | */
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 | /*! \fn void QButtonGroup::insert(QAbstractButton *b)
|
|---|
| 253 |
|
|---|
| 254 | Use addButton() instead.
|
|---|
| 255 | */
|
|---|
| 256 |
|
|---|
| 257 | /*! \fn void QButtonGroup::remove(QAbstractButton *b)
|
|---|
| 258 |
|
|---|
| 259 | Use removeButton() instead.
|
|---|
| 260 | */
|
|---|