当前位置:网站首页>(5) Pyqt5 ---- another method of connecting signals and slots
(5) Pyqt5 ---- another method of connecting signals and slots
2022-06-25 12:36:00 【haoming Hu】
GitHub Connect :
This column all source code GitHub Through train
It's a little strange
But after learning this way , I don't think it's that flexible, right , This will be mentioned later
Look at the code first
Main program code :
""" /******************************************************************************** * @Filename: Decorator signal and slot .py * @Author: haomingHu * @Version: 1.0 * @Date: 2020-12-16 * @Description: * @History: ********************************************************************************/ """
from ui4 import Ui_Form# Import on QTdesigner Well designed ui.py file
import sys
from PyQt5 import QtWidgets,QtCore
class mydesigner(QtWidgets.QWidget,Ui_Form):
def __init__(self):
super(mydesigner,self).__init__()
self.setupUi(self)
QtCore.QMetaObject.connectSlotsByName(self)
@QtCore.pyqtSlot()
def on_open_clicked(self):
self.calendarWidget.close()
@QtCore.pyqtSlot()
def on_close_clicked(self):
self.calendarWidget.show()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
myshow = mydesigner()
myshow.show()
sys.exit(app.exec_())
ui File code :
""" /******************************************************************************** * @Filename: ui4.py * @Author: haomingHu * @Version: 1.0 * @Date: 2020-12-16 * @Description: * @History: ********************************************************************************/ """
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui4.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(432, 325)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(40, 220, 75, 23))
self.pushButton.setObjectName("open")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(290, 220, 75, 23))
self.pushButton_2.setObjectName("close")
self.calendarWidget = QtWidgets.QCalendarWidget(Form)
self.calendarWidget.setGeometry(QtCore.QRect(80, 10, 248, 197))
self.calendarWidget.setObjectName("calendarWidget")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "PushButton"))
self.pushButton_2.setText(_translate("Form", "PushButton"))
Just look at the rest of the code , Look at the following lines of code :
@QtCore.pyqtSlot()
def on_open_clicked(self):
self.calendarWidget.close()
@QtCore.pyqtSlot()
def on_close_clicked(self):
self.calendarWidget.show()
First , The premise of using this method is to execute the following line of code first ,( This line of code is in setupUi The function has )
QtCore.QMetaObject.connectSlotsByName(Form)
This line of code is pyqt5 Automatically connect to the core code of slot function according to the signal name in , This line of code is used to put QObject Some of the signals of a neutron object follow its objextName Connect to the corresponding slot function summary ,
Secondly, the connection format is :
@QtCore.pyqtSlot()
def on_objectSignal_function(self):
objectName It's the name of the control
function The signal of the control to be connected , Here is the click signal clicked
One problem with whimsy is , If my objectName It's a Chinese name , So this one functionName Isn't it very awkward !!
ok , That's all , As for this method, how to produce parameters , It's the same feeling emit equally , About the same !
边栏推荐
- PHP multidimensional array sorting
- Laravel multi project mutual access
- Image tagging to obtain the coordinates of the image in the ImageView
- Today, I will explain to you what is DFI and its development prospects
- [oceanbase] Introduction to oceanbase and its comparison with MySQL
- Penetration tool environment - installing sqli labs in centos7 environment
- ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities
- JQ dynamic setting radio does not take effect when selected
- The network traceroute command is used to determine the path through which IP packets access the destination address.
- Zhangxiaobai's road of penetration (VI) -- the idea and process of SQL injection and the concat series functions and information of SQL_ Schema database explanation
猜你喜欢
[oceanbase] Introduction to oceanbase and its comparison with MySQL
Today, I will explain to you what is DFI and its development prospects
Zhangxiaobai's way of penetration (VIII) - detailed operation steps of SQL injection - Boolean blind injection of blind injection
Laravel excel export
Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
[regression analysis] understand ridge regression with case teaching
[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer
19. Implementation of MVVM architecture based on WPF event to command
A set of automated paperless office system (oa+ approval process) source code: with data dictionary
Flutter common commands and problems
随机推荐
Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability
Penetration tool environment - Installation of sqlmap
Error while sending STMT_ PREPARE packet. PID=29294
Huile optimization system -- sharing of secondary development source code of huile optimization app system
node. JS architecture optimization: reverse proxy and cache service
The source code of the hottest online disk money making system in 2022 imitates Lanzou online disk / Chengtong online disk / sharing money making cloud disk system / online disk VIP Download System
Recyclerview scrolls to the specified location
If you also want to be we media, you might as well listen to Da Zhou's advice
Ubuntu uninstalling PHP
Qiantang Pingou source code -- Qiantang Pingou app system development source code sharing
ECSHOP quickly purchases goods, simplifies the shopping process, and improves the user experience through one-step shopping
Full nanny tutorial of Market Research Competition (experience sharing)
Jeecgboot startup popup configuration is still incorrect
Ten commandments of self-learning in machine learning
Time series analysis - how to use unit root test (ADF) correctly?
ARM 立即数
2022 Baidu collection batch automatic push assistant
laravel 9
PHP replaces the key of a two-dimensional array with a specified element value
PHP files running online