PyQt6는 21년 2월 6일에 6.0.0.1 Version이 배포 되었습니다.
기본적인 hello world를 출력해보도록 하겠습니다.
<PyQt5>
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
def helloworld():
app = QApplication(sys.argv)
widget = QWidget()
textLabel = QLabel(widget)
textLabel.setText("Hello World!")
textLabel.move(150, 200)
widget.setGeometry(50, 50, 400, 400)
widget.setWindowTitle("PyQt5 Example")
widget.show()
sys.exit(app.exec_())
프로그램무한반복 = QApplication(sys.argv)
실행인스턴스 = helloworld()
프로그램무한반복.exec_()
<PyQt6>
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLabel
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import pyqtSlot
def helloworld():
app = QApplication(sys.argv)
widget = QWidget()
textLabel = QLabel(widget)
textLabel.setText("Hello World!")
textLabel.move(150, 200)
widget.setGeometry(50, 50, 400, 400)
widget.setWindowTitle("PyQt5 Example")
widget.show()
sys.exit(app.exec())
프로그램무한반복 = QApplication(sys.argv)
실행인스턴스 = helloworld()
프로그램무한반복.exec()
위 두 코드의 차이점은 아래와 같습니다.
공식문서에는 어떤 내용이 담겨있는지 한 번 살펴보도록 하겠습니다.
Differences Between PyQt6 and PyQt5 - PyQt v6.1 Reference Guide
아래 영문 스크립트를 가져왔습니다.
In this section we give an overview of the differences between PyQt6 and PyQt5. This is not an exhaustive list and does not go into the detail of the differences between the Qt v6 and Qt v5 APIs.
Enum
class. (PyQt5 used IntEnum
for scoped enums and a custom type for traditional named enums).QFlags
template class as a type-safe way of using enum values that can be combined as a set of flags. The name of the class is often the plural form of the name of the enum. PyQt5 implements both of these as separate types. PyQt6 instead combines them as a single type, using the name of the enum, as a sub-class of Flag
.Q_CLASSINFO()
has been replaced by the pyqtClassInfo() class decorator.Q_ENUM()
, Q_ENUMS()
, Q_FLAG()
and Q_FLAGS()
have been replaced by the pyqtEnum() class decorator.exec_()
and print_()
methods have been removed.