?print-pdf
' Created for
Qt (pronounced "cute") framework is a widget toolkit for creating GUIs as well as cross-platform applications that run on various software and hardware platforms such as Linux, Windows, macOS, Android or embedded systems with little or no change in the underlying codebase while still being a native application with native capabilities and speed.[Reference: Qt @wikipediq]
# on activated virtual environment:
pip install PyQt6
# check install info:
pip show PyQt6
pyqt_test.py
file and run it.
import sys
from PyQt6.QtWidgets import QApplication,QWidget
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle('PyQt6 App Works')
window.setGeometry(100, 100, 500, 500)
window.show()
sys.exit(app.exec())
You should see a window like:
Qt Designer normally ships as a part of Qt Creator. This is Qt's official editor and lets you do a lot more than just graphically design user interfaces. It is a full-fledged and very powerful C++ IDE. But For PyQt development you don't need the whole Qt Creator (which is huge).
You can install only the Qt Designer in two ways:
# make sure you're on activated virtual environment:
pip install pyqt6-tools
# check install info:
pip show pyqt6-tools
pyuic6
is included in the PyQt6-tools
, so you do not need to install it. Just use it.
pyuic6 helloWorld.ui -o helloWorld.py
PyQt Integration
in the search bar.You need to perform next steps only if you don't have PyQt6
, PyQt6-sip
and PyQt6-tools
packages
File => Settings => Tools => External Tools
click the +
buttonFile => Settings => Tools => External Tools
click the +
buttonui
file with QtDesigner
import sys
from PyQt6.QtWidgets import (
QApplication, QMainWindow
)
from helloWorld import Ui_MainWindow
class Window(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
if __name__ == "__main__":
app = QApplication(sys.argv)
win = Window()
win.show()
sys.exit(app.exec())
Template | Form Type | Widgets | Base Class |
---|---|---|---|
Dialog with Buttons Bottom | Dialog | OK and Cancel buttons laid out horizontally on the bottom-right corner | QDialog |
Dialog with Buttons Right | Dialog | OK and Cancel buttons laid out vertically on the top-right corner | QDialog |
Dialog without Buttons | Dialog | No | QDialog |
Main Window | Main Window | A menu bar at the top and a status bar at the bottom | QMainWindow |
Widget | Widget | No | QWidget |
The Qt team maintains a thorough documentation, as well as user guides, tutorials, etc. for working wit QtDesigner
my_first_GUI.ui
my_first_GUI.ui
file to python code, using the pyuic6
toolmy_first_GUI_app.py
which will start a Qt App and shows the GUI created by you with QtDesigner.Try to make an app, which will have the widgets given on next picture: