PyQt is a cross-platform toolkit for creating GUI applications that integrates Python with the Qt library.
That is, PyQt allows the use of the Python language to call APl from the Qt library, greatly improving development efficiency while retaining Qt's high operational efficiency.
Because it's much faster to develop programs in Python than in C++, PyQt wraps Qt completely and can do almost anything Qt can do with PyQt.
import sys
from PyQt5.QtWidgets import QApplication,QWidget
if __name__ == '__main__':
app = QApplication(sys.argv) # Create an instance of the QApplication class
w = QWidget() #Create a window
w.resize(400,200) #Setting the window size
w.move(300,300) #move window
w.setWindowTitle("The first PyQt5-based desktop application") #setWindowTitle
w.show() #display window
sys.exit(app.exec_()) #Enters the main loop of the program and ensures the main loop ends safely with the exit function
The function of app.exec_() is to run the main loop, which must be called to start the event processing, and the method is called to enter the main loop of the program until the exit() is called.
If you are new to PyQt, I recommend this book
QApplication
The QApplication class manages the control flow and major settings of GUI applications. It can be said that QApplication is the lifeblood of Qt's entire back-office management.
app = QApplication(sys.argv) # Create an instance of the QApplication class
It contains the main event loop in which all events from the window system and other resources are processed and scheduled.
It also handles the initialization and termination of applications and provides conversation management. It also handles most system-wide and application-wide settings.
For any GUI application that uses Qt, there has to be a QApplication object
QWidget
The QWidget class is the base class for all user interface objects. This includes buttons, labels, text input, progressbar, messagebox and a lot more.
QDialog
The QDialog class is the base class of the dialog window. This lets you create dialogs.
QMainWindow
The QMainWindow class provides a main application window with menu bars, toolbars, status bars (e.g., IDE-Visual Studio, Qt Creator, etc.) that is commonly used for developing Qt.
A main window provides the user interface framework for building the application. qt has QMainWindow and its related classes to manage the main window
QWebEngineView
PyQt5 uses the QWebEngineView control to display HTML pages. Older versions of the QWebView class are not maintained because QWebEngineView uses the Chromium kernel to give users a better experience.
Top comments (0)