1. Each app must create a qtgui.qapplication (SYS.ARGV), at which point Qtgui.qapp an instance of this app
App =# because exec is a keyword, so Qt uses the exec_, APP.EXEC_ () to represent a loop into the
2. All interface graphics classes are inherited from Qtgui.qwidget, such as Qtgui.qpushbutton can use Setgeometry () and other methods, Qwidget If the parent is not specified, then it is the top-level window a
3.qtgui.qpushbutton (' Quit ', widget), create a Qpushbutton instance, put it on the widget
The 4.pyqt4 event processing system is based on the signal-slot
The slot details can be referenced in the following two articles, PYQT4 signal and Groove usage summary, signal and slot details
The signal and slot mechanism, as the most important feature of QT, provides a communication mechanism between any two Qt objects, which is triggered by a particular case or action, and the slot is a function for receiving and processing the signal.
Each Qt object contains predetermined signals and slots, and when a particular event occurs, a signal is emitted, and the slot associated with the signal responds to the signal to complete the corresponding processing
The signal-to-slot mechanism is commonly connected by connect (object1,signal (SIGNAL), Object2,slot (slot)), where the slot function can be a slot function that comes with PyQt, or a custom slot function (@ Qtcore.pyqtslot ()), or even any function that can be called by Python
W.connect (BTN, Qtcore.signal ("clicked ()"), Qtgui.qapp, Qtcore.slot ("Quit ( )"))
Or
#Coding:utf-8 fromPyQt4ImportQtgui, Qtcoreapp=qtgui.qapplication ([]) W=Qtgui.qwidget ()defshowmsg (): QtGui.QMessageBox.information (w, u"Information"+ R"OK") btn= Qtgui.qpushbutton (U"Point Me", W) w.connect (BTN, Qtcore.signal ("clicked ()"), showmsg)#or Btn.clicked.connect (showmsg)w.show () app.exec_ ( )
The clicked () signal of the button object is connected to the SHOWMSG function, which means that showmsg responds to a button's Click event
Aa
PYTHON-PYQT4 Study Notes