# QCheckBox

## 생성

```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 값과 같은지 비교를 합니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://study-code.gitbook.io/python-basic/qtpy/pyqt-widget/qcheckbox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
