QButtonGroup Class
QButtonGroup 클래스는 버튼 위젯의 그룹을 구성하는 컨테이너를 제공합니다. 더 보기...
Header: | #include <QButtonGroup> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
상속합니다: | QObject |
속성
- exclusive : bool
공공 기능
QButtonGroup(QObject *parent = nullptr) | |
virtual | ~QButtonGroup() |
void | addButton(QAbstractButton *button, int id = -1) |
QAbstractButton * | button(int id) const |
QList<QAbstractButton *> | buttons() const |
QAbstractButton * | checkedButton() const |
int | checkedId() const |
bool | exclusive() const |
int | id(QAbstractButton *button) const |
void | removeButton(QAbstractButton *button) |
void | setExclusive(bool) |
void | setId(QAbstractButton *button, int id) |
신호
void | buttonClicked(QAbstractButton *button) |
void | buttonPressed(QAbstractButton *button) |
void | buttonReleased(QAbstractButton *button) |
void | buttonToggled(QAbstractButton *button, bool checked) |
void | idClicked(int id) |
void | idPressed(int id) |
void | idReleased(int id) |
void | idToggled(int id, bool checked) |
상세 설명
QButtonGroup은 버튼 위젯을 배치할 수 있는 추상 컨테이너를 제공합니다. 이 컨테이너의 시각적 표현은 제공하지 않지만(컨테이너 위젯은 QGroupBox 참조), 대신 그룹에 있는 각 버튼의 상태를 관리합니다.
exclusive 버튼 그룹은 클릭한 버튼을 제외한 모든 체크(토글) 버튼을 끕니다. 기본적으로 버튼 그룹은 독점적입니다. 버튼 그룹의 버튼은 일반적으로 QPushButtons, QCheckBoxes(일반적으로 비독점 버튼 그룹의 경우) 또는 QRadioButtons로 체크할 수 있습니다. 독점 버튼 그룹을 만드는 경우 그룹 내 버튼 중 하나가 처음에 체크되어 있는지 확인해야 하며, 그렇지 않으면 그룹은 처음에 체크된 버튼이 없는 상태가 됩니다.
addButton()를 사용하여 그룹에 버튼을 추가하고 removeButton()를 사용하여 버튼을 제거할 수 있습니다. 그룹이 독점인 경우 현재 체크된 버튼은 checkedButton()로 사용할 수 있습니다. 버튼을 클릭하면 buttonClicked() 신호가 발생하며, 독점 그룹에서 확인 가능한 버튼의 경우 이는 해당 버튼이 확인되었음을 의미합니다. 그룹의 버튼 목록은 buttons()로 반환됩니다.
또한 QButtonGroup은 정수와 버튼 간에 매핑할 수 있습니다. setId ()로 버튼에 정수 ID를 할당하고 id()로 검색할 수 있습니다. 현재 체크된 버튼의 아이디는 checkedId()로 확인할 수 있으며, 버튼의 아이디를 방출하는 신호 idClicked()가 있습니다. -1
아이디는 "해당 버튼 없음"을 의미하기 위해 QButtonGroup에 의해 예약되어 있습니다. 매핑 메커니즘의 목적은 사용자 인터페이스에서 열거형 값의 표현을 단순화하기 위한 것입니다.
QGroupBox, QPushButton, QCheckBox, QRadioButton 를참조하세요 .
속성 문서
exclusive : bool
이 속성은 버튼 그룹이 독점적인지 여부를 보유합니다.
이 속성이 true
인 경우 그룹에서 한 번에 하나의 버튼만 확인할 수 있습니다. 사용자는 아무 버튼이나 클릭하여 체크할 수 있으며, 해당 버튼은 그룹에서 기존 버튼을 체크된 버튼으로 대체합니다.
독점 그룹에서는 사용자가 현재 선택된 버튼을 클릭하여 선택을 취소할 수 없으며, 그룹의 다른 버튼을 클릭하여 해당 그룹에 대한 새 선택된 버튼을 설정해야 합니다.
기본적으로 이 속성은 true
입니다.
액세스 함수:
bool | exclusive() const |
void | setExclusive(bool) |
멤버 함수 문서
[explicit]
QButtonGroup::QButtonGroup(QObject *parent = nullptr)
주어진 parent 으로 새로운 빈 버튼 그룹을 생성합니다.
addButton() 및 setExclusive()도 참조하세요 .
[virtual noexcept]
QButtonGroup::~QButtonGroup()
버튼 그룹을 삭제합니다.
void QButtonGroup::addButton(QAbstractButton *button, int id = -1)
지정된 button 을 버튼 그룹에 추가합니다. id 이 -1이면 버튼에 아이디가 할당됩니다. 자동으로 할당된 아이디는 -2부터 시작하여 음수가 되도록 보장됩니다. 직접 아이디를 할당하는 경우 충돌을 피하기 위해 양수 값을 사용하세요.
removeButton() 및 buttons()도 참조하세요 .
QAbstractButton *QButtonGroup::button(int id) const
지정된 id, 또는 해당 버튼이 없는 경우 nullptr
버튼을 반환합니다.
[signal]
void QButtonGroup::buttonClicked(QAbstractButton *button)
이 신호는 지정된 button 을 클릭할 때 발생합니다. 버튼을 처음 눌렀다가 놓거나 바로 가기 키를 입력하거나 QAbstractButton::click() 또는 QAbstractButton::animateClick()가 프로그래밍 방식으로 호출되면 버튼이 클릭됩니다.
checkedButton() 및 QAbstractButton::clicked()도 참조하세요 .
[signal]
void QButtonGroup::buttonPressed(QAbstractButton *button)
이 신호는 지정된 button 을 눌렀을 때 방출됩니다.
QAbstractButton::pressed()도 참조하세요 .
[signal]
void QButtonGroup::buttonReleased(QAbstractButton *button)
이 신호는 지정된 button 이 릴리스될 때 방출됩니다.
QAbstractButton::released()도 참조하세요 .
[signal]
void QButtonGroup::buttonToggled(QAbstractButton *button, bool checked)
button checked 버튼이 체크되어 있으면 참이고, 체크되지 않으면 거짓입니다.
QAbstractButton::toggled()도 참조하세요 .
QList<QAbstractButton *> QButtonGroup::buttons() const
버튼 그룹의 버튼 목록을 반환합니다. 비어 있을 수 있습니다.
addButton() 및 removeButton()도 참조하세요 .
QAbstractButton *QButtonGroup::checkedButton() const
버튼 그룹의 체크된 버튼을 반환하거나, 체크된 버튼이 없는 경우 nullptr
을 반환합니다.
buttonClicked()도 참조하세요 .
int QButtonGroup::checkedId() const
checkedButton()의 아이디를 반환하며, 선택된 버튼이 없으면 -1을 반환합니다.
setId()도 참조하세요 .
int QButtonGroup::id(QAbstractButton *button) const
지정된 button 의 아이디를 반환하거나 해당 버튼이 없는 경우 -1을 반환합니다.
setId()도 참조하세요 .
[signal]
void QButtonGroup::idClicked(int id)
이 신호는 지정된 id 버튼이 클릭될 때 발생합니다.
checkedButton() 및 QAbstractButton::clicked()도 참조하세요 .
[signal]
void QButtonGroup::idPressed(int id)
이 신호는 지정된 id 버튼이 아래로 눌려질 때 방출됩니다.
QAbstractButton::pressed()도 참조하세요 .
[signal]
void QButtonGroup::idReleased(int id)
이 신호는 지정된 id 버튼이 해제될 때 방출됩니다.
QAbstractButton::released()도 참조하세요 .
[signal]
void QButtonGroup::idToggled(int id, bool checked)
이 신호는 지정된 id 버튼이 토글될 때 발생합니다. checked 버튼이 체크되어 있으면 참이고, 체크되지 않으면 거짓입니다.
QAbstractButton::toggled()도 참조하세요 .
void QButtonGroup::removeButton(QAbstractButton *button)
지정된 button 을 버튼 그룹에서 제거합니다.
addButton() 및 buttons()도 참조하세요 .
void QButtonGroup::setId(QAbstractButton *button, int id)
지정된 button 에 대해 id 을 설정합니다. id 은 -1 이 될 수 없습니다.
id()도 참조하세요 .
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.