> For the complete documentation index, see [llms.txt](https://study-code.gitbook.io/python-basic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://study-code.gitbook.io/python-basic/qtpy/pyqt-widget/qcheckbox.md).

# QCheckBox

선택, 선택하지 않음 두 가지 상태값을 가진 CheckBox 위젯입니다.

## 생성

```python
# -*- coding: UTF-8 -*-
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
class App(QCheckBox) :
    def __init__(self):
        super(App, self).__init__()
        self.setWindowTitle('Window!!!')
        self.resize(600,600)
        self.setStyleSheet('color:red;font-size:45px;')
        self.setText('확인')
if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = App()
    window.show()
    sys.exit(app.exec_())
```

## 체크 상태 변경

```python
# -*- coding: UTF-8 -*-
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
class App(QCheckBox) :
    def __init__(self):
        super(App, self).__init__()
        self.setWindowTitle('Window!!!')
        self.resize(600,600)
        self.setStyleSheet('color:red;font-size:45px;')
        self.setText('확인')
        self.stateChanged.connect(self.changeCheckState)
    def changeCheckState(self, state):
        if state == Qt.Checked:
            self.setText("Checked!!")
        else :
            self.setText("Unchecked!!")
if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = App()
    window.show()
    sys.exit(app.exec_())
```

13  stateChanged(상태가 변경되면) .connect(어떤일을 수행하겠다)\
14  13번 라인의 connect에 의해 연결고리가 맺어지면 changeCheckState 함수가 호출될 때 state 값이 넘어 옵니다.\
&#x20;      이때 넘어오는 값이 Qt.Checked 값과 같은지 비교를 합니다.
