Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQuickButtonGroupPrivate Class Reference

Mutually-exclusive group of checkable buttons. More...

Inheritance diagram for QQuickButtonGroupPrivate:
Collaboration diagram for QQuickButtonGroupPrivate:

Public Member Functions

void clear ()
void buttonClicked ()
void _q_updateCurrent ()
void updateCheckState ()
void setCheckState (Qt::CheckState state)
void clear ()
void buttonClicked ()
void _q_updateCurrent ()
void updateCheckState ()
void setCheckState (Qt::CheckState state)
Public Member Functions inherited from QObjectPrivate
void ensureExtraData ()
void setObjectNameWithoutBindings (const QString &name)
 QObjectPrivate (decltype(QObjectPrivateVersion) version=QObjectPrivateVersion)
virtual ~QObjectPrivate ()
void deleteChildren ()
void clearBindingStorage ()
void setParent_helper (QObject *)
void moveToThread_helper ()
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData, QBindingStatus *status)
QObjectList receiverList (const char *signal) const
void ensureConnectionData ()
void addConnection (int signal, Connection *c)
int signalIndex (const char *signalName, const QMetaObject **meta=nullptr) const
bool isSignalConnected (uint signalIdx, bool checkDeclarative=true) const
bool maybeSignalConnected (uint signalIndex) const
bool isDeclarativeSignalConnected (uint signalIdx) const
void connectNotify (const QMetaMethod &signal)
void disconnectNotify (const QMetaMethod &signal)
void reinitBindingStorageAfterThreadMove ()
virtual std::string flagsForDumping () const
virtual void writeToDebugStream (QDebug &) const
QtPrivate::QPropertyAdaptorSlotObjectgetPropertyAdaptorSlotObject (const QMetaProperty &property)
Public Member Functions inherited from QObjectData
 QObjectData ()=default
virtual ~QObjectData ()=0
const QMetaObjectdynamicMetaObject () const

Static Public Member Functions

static void buttons_append (QQmlListProperty< QQuickAbstractButton > *prop, QQuickAbstractButton *obj)
static qsizetype buttons_count (QQmlListProperty< QQuickAbstractButton > *prop)
static QQuickAbstractButtonbuttons_at (QQmlListProperty< QQuickAbstractButton > *prop, qsizetype index)
static void buttons_clear (QQmlListProperty< QQuickAbstractButton > *prop)
static void buttons_append (QQmlListProperty< QQuickAbstractButton > *prop, QQuickAbstractButton *obj)
static qsizetype buttons_count (QQmlListProperty< QQuickAbstractButton > *prop)
static QQuickAbstractButtonbuttons_at (QQmlListProperty< QQuickAbstractButton > *prop, qsizetype index)
static void buttons_clear (QQmlListProperty< QQuickAbstractButton > *prop)
Static Public Member Functions inherited from QObjectPrivate
static bool removeConnection (Connection *c)
static QObjectPrivateget (QObject *o)
static const QObjectPrivateget (const QObject *o)
template<typename Func1, typename Func2>
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
template<typename Func1, typename Func2>
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
static QMetaObject::Connection connectImpl (const QObject *sender, int signal_index, const QObject *receiver, void **slot, QtPrivate::QSlotObjectBase *slotObj, int type, const int *types, const QMetaObject *senderMetaObject)
static QMetaObject::Connection connect (const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type)
static QMetaObject::Connection connect (const QObject *sender, int signal_index, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type)
static bool disconnect (const QObject *sender, int signal_index, void **slot)
static bool disconnect (const QObject *sender, int signal_index, const QObject *receiver, void **slot)

Public Attributes

bool complete = true
bool exclusive = true
bool settingCheckState = false
Qt::CheckState checkState = Qt::Unchecked
QPointer< QQuickAbstractButtoncheckedButton
QList< QQuickAbstractButton * > buttons
Public Attributes inherited from QObjectPrivate
ExtraDataextraData
QAtomicPointer< QThreadDatathreadData
QAtomicPointer< ConnectionDataconnections
union { 
   QObject *   currentChildBeingDeleted 
   QAbstractDeclarativeData *   declarativeData 
}; 
QAtomicPointer< QtSharedPointer::ExternalRefCountDatasharedRefcount
Public Attributes inherited from QObjectData
QObjectq_ptr
QObjectparent
QObjectList children
uint isWidget: 1
uint blockSig: 1
uint wasDeleted: 1
uint isDeletingChildren: 1
uint sendChildEvents: 1
uint receiveChildEvents: 1
uint isWindow: 1
uint deleteLaterCalled: 1
uint isQuickItem: 1
uint willBeWidget: 1
uint wasWidget: 1
uint receiveParentEvents: 1
uint unused: 20
QAtomicInt postedEvents
QDynamicMetaObjectDatametaObject
QBindingStorage bindingStorage

Additional Inherited Members

Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
using ConnectionDataPointer = QExplicitlySharedDataPointer<ConnectionData>

Detailed Description

Mutually-exclusive group of checkable buttons.

\qmltype ButtonGroup
\inherits QtObject

! \nativetype QQuickButtonGroup \inqmlmodule QtQuick.Controls

Since
5.7

ButtonGroup is a non-visual, mutually exclusive group of buttons. It is used with controls such as RadioButton, where only one of the options can be selected at a time.

The most straight-forward way to use ButtonGroup is to assign a list of buttons. For example, the list of children of a \l{Item Positioners}{positioner} or a \l{Qt Quick Layouts}{layout} that manages a group of mutually exclusive buttons.

ButtonGroup {
buttons: column.children
}
Column {
RadioButton {
checked: true
text: qsTr("DAB")
}
RadioButton {
text: qsTr("FM")
}
RadioButton {
text: qsTr("AM")
}
}
QList< QQuickAbstractButton * > buttons
GLenum GLuint id
GLenum GLenum GLsizei void GLsizei void * column

Mutually exclusive buttons do not always share the same parent item, or the parent layout may sometimes contain items that should not be included in the button group. Such cases are best handled using the \l group attached property.

ButtonGroup { id: radioGroup }
Column {
Label {
text: qsTr("Radio:")
}
RadioButton {
checked: true
text: qsTr("DAB")
ButtonGroup.group: radioGroup
}
RadioButton {
text: qsTr("FM")
ButtonGroup.group: radioGroup
}
RadioButton {
text: qsTr("AM")
ButtonGroup.group: radioGroup
}
}
GLboolean GLuint group
[16]

Another option is to filter the list of children. This is especially handy if you're using a repeater to populate it, since the repeater will also be a child of the parent layout:

ButtonGroup {
buttons: column.children.filter((child) => child !== repeater)
}
Column {
Repeater {
id: repeater
model: [ qsTr("DAB"), qsTr("AM"), qsTr("FM") ]
RadioButton {
required property string modelData
text: modelData
}
}
}
QSqlQueryModel * model
[16]
QLayoutItem * child
[0]

More advanced use cases can be handled using the addButton() and removeButton() methods.

See also
RadioButton, {Button Controls}

\qmlsignal QtQuick.Controls::ButtonGroup::clicked(AbstractButton button)

Since
QtQuick.Controls 2.1 (Qt 5.8)

This signal is emitted when a button in the group has been clicked.

This signal is convenient for implementing a common signal handler for all buttons in the same group.

ButtonGroup {
buttons: column.children
onClicked: button => {
console.log("clicked:", button.text)
}
}
Column {
Button { text: "First" }
Button { text: "Second" }
Button { text: "Third" }
}
Button
QPushButton * button
[0]
See also
AbstractButton::clicked()

Definition at line 145 of file qquickbuttongroup.cpp.

Member Function Documentation

◆ _q_updateCurrent() [1/2]

void QQuickButtonGroupPrivate::_q_updateCurrent ( )

Definition at line 193 of file qquickbuttongroup.cpp.

References exclusive, and updateCheckState().

Here is the call graph for this function:

◆ _q_updateCurrent() [2/2]

void QQuickButtonGroupPrivate::_q_updateCurrent ( )

◆ buttonClicked() [1/2]

void QQuickButtonGroupPrivate::buttonClicked ( )

Definition at line 185 of file qquickbuttongroup.cpp.

◆ buttonClicked() [2/2]

void QQuickButtonGroupPrivate::buttonClicked ( )

◆ buttons_append() [1/2]

void QQuickButtonGroupPrivate::buttons_append ( QQmlListProperty< QQuickAbstractButton > * prop,
QQuickAbstractButton * obj )
static

Definition at line 231 of file qquickbuttongroup.cpp.

◆ buttons_append() [2/2]

void QQuickButtonGroupPrivate::buttons_append ( QQmlListProperty< QQuickAbstractButton > * prop,
QQuickAbstractButton * obj )
static

◆ buttons_at() [1/2]

QQuickAbstractButton * QQuickButtonGroupPrivate::buttons_at ( QQmlListProperty< QQuickAbstractButton > * prop,
qsizetype index )
static

Definition at line 243 of file qquickbuttongroup.cpp.

◆ buttons_at() [2/2]

QQuickAbstractButton * QQuickButtonGroupPrivate::buttons_at ( QQmlListProperty< QQuickAbstractButton > * prop,
qsizetype index )
static

◆ buttons_clear() [1/2]

void QQuickButtonGroupPrivate::buttons_clear ( QQmlListProperty< QQuickAbstractButton > * prop)
static

Definition at line 249 of file qquickbuttongroup.cpp.

◆ buttons_clear() [2/2]

void QQuickButtonGroupPrivate::buttons_clear ( QQmlListProperty< QQuickAbstractButton > * prop)
static

◆ buttons_count() [1/2]

qsizetype QQuickButtonGroupPrivate::buttons_count ( QQmlListProperty< QQuickAbstractButton > * prop)
static

Definition at line 237 of file qquickbuttongroup.cpp.

◆ buttons_count() [2/2]

qsizetype QQuickButtonGroupPrivate::buttons_count ( QQmlListProperty< QQuickAbstractButton > * prop)
static

◆ clear() [1/2]

void QQuickButtonGroupPrivate::clear ( )

Definition at line 169 of file qquickbuttongroup.cpp.

◆ clear() [2/2]

void QQuickButtonGroupPrivate::clear ( )

◆ setCheckState() [1/2]

void QQuickButtonGroupPrivate::setCheckState ( Qt::CheckState state)

Definition at line 221 of file qquickbuttongroup.cpp.

◆ setCheckState() [2/2]

void QQuickButtonGroupPrivate::setCheckState ( Qt::CheckState state)

◆ updateCheckState() [1/2]

void QQuickButtonGroupPrivate::updateCheckState ( )

Definition at line 206 of file qquickbuttongroup.cpp.

References complete, and settingCheckState.

Referenced by _q_updateCurrent().

Here is the caller graph for this function:

◆ updateCheckState() [2/2]

void QQuickButtonGroupPrivate::updateCheckState ( )

Member Data Documentation

◆ buttons

QList< QQuickAbstractButton * > QQuickButtonGroupPrivate::buttons

Definition at line 166 of file qquickbuttongroup.cpp.

◆ checkedButton

QPointer< QQuickAbstractButton > QQuickButtonGroupPrivate::checkedButton

Definition at line 165 of file qquickbuttongroup.cpp.

◆ checkState

Qt::CheckState QQuickButtonGroupPrivate::checkState = Qt::Unchecked

Definition at line 164 of file qquickbuttongroup.cpp.

◆ complete

bool QQuickButtonGroupPrivate::complete = true

Definition at line 161 of file qquickbuttongroup.cpp.

Referenced by updateCheckState().

◆ exclusive

bool QQuickButtonGroupPrivate::exclusive = true

Definition at line 162 of file qquickbuttongroup.cpp.

Referenced by _q_updateCurrent().

◆ settingCheckState

bool QQuickButtonGroupPrivate::settingCheckState = false

Definition at line 163 of file qquickbuttongroup.cpp.

Referenced by updateCheckState().


The documentation for this class was generated from the following file: