> 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/qpushbutton.md).

# QPushButton

## 생성

```python
# -*- coding: UTF-8 -*-
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
class App(QPushButton) :
    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(QPushButton) :
    def __init__(self):
        super(App, self).__init__()
        self.setWindowTitle('Window!!!')
        self.resize(600,600)
        self.setStyleSheet('color:red;font-size:45px;')
        self.setText('확인')
        self.clicked.connect(self.onClick)
    def onClick(self):
        print('Click!!!')
if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = App()
    window.show()
    sys.exit(app.exec_())
```

13  버튼에 click(클릭이벤트)가 발생했을 때 .connect(어떤 일을 수행할지) 옵션을 추가합니다.\
14  클릭이 일어났을 때 Click!! 이라는 문자를 출력하도록 함수를 만듭니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/qpushbutton.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.
