-
-
Notifications
You must be signed in to change notification settings - Fork 2
Crash Course: Qt
At it's core, a Qt app is this:
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
window.show()
sys.exit(app.exec_())
The core app: QtWidgets.QApplication
takes arguments from the terminal via sys.argv
The main window: QtWidgets.QWidget
is created and shown with the .show()
method
Finally, the application returns an exit code to the terminal with sys.exit(app.exec_())
Qt has many modules, all with the naming convention of QtModule
Examples include: QtCore, QtWidgets & QtScript
If you find a handy C++ class in the Qt Documentation, you need to check the qmake
field at the top of it's page
This will tell you the appropriate python module name to import: qmake: QT += widgets
== QtWidgets
QtPyHammer subclasses a number of Qt C++ Classes to create widgets
The ui.viewport
class is a subclass of QtWidgets.QOpenGLWidget
One of the most important differences between it's parent C++ class and the QPH class is the addition of a timer to redraw the viewport every 15ms