当前位置: 首页 > news >正文

asp如何做网站肇庆正规网页设计培训试听

asp如何做网站,肇庆正规网页设计培训试听,应聘的做网站推广的,磁力宝在上一篇文章中python之pyqt专栏6-信号与槽2-CSDN博客中#xff0c;我们可以了解到对象可以使用内置信号#xff0c;这些信号来自于类定义或者继承过来的。我们可以对这些信号可以通过connect连接槽函数。 需求 现在有一个需求#xff0c;有两个UI界面“untitled.ui”和“u… 在上一篇文章中python之pyqt专栏6-信号与槽2-CSDN博客中我们可以了解到对象可以使用内置信号这些信号来自于类定义或者继承过来的。我们可以对这些信号可以通过connect连接槽函数。 需求 现在有一个需求有两个UI界面“untitled.ui”和“untitled1.ui”untitled.ui有一个lineEdit行编辑和一个button按钮untitled1.ui有一个Label。点击untitled.ui的button时将行编辑的文本内容设置为untitled1.ui的Label文本内容。 untitled.ui的对象列表 对象名类型lineEditLlineEditpushButtonQPushButto untitled1.ui的对象列表 对象名类型labelQLabel UI界面设置 untitled.ui  UI界面 保存文件为untitled.ui untitled1.ui  UI界面 点击左上角“文件”-“新建” 保存文件为untitled.ui  注Qt Designer中当有两个以上的UI编辑界面时需要先选中的UI界面再保存 项目目录下“untitled.ui”和“untitled1.ui”转换为“untitled.py”和“untitled1.py” main.py # 导入sys模块 import sys # PyQt6.QtWidgets模块中导入QApplication, QWidget from PyQt6.QtWidgets import QApplication, QWidget from PyQt6.QtCore import QObjectimport untitled import untitled1class MyMainForm(QWidget, untitled.Ui_Form):sendText pyqtSignal(str)def __init__(self, parentNone):# 调用父类的构造函数super(MyMainForm, self).__init__(parent)# 调用继承Ui_Form过来的setupUi函数self.setupUi(self)self.pushButton.clicked.connect(self.btn_clicked)class MyMainForm1(QWidget, untitled1.Ui_Form):def __init__(self, parentNone):# 调用父类的构造函数super(MyMainForm1, self).__init__(parent)# 调用继承Ui_Form过来的setupUi函数self.setupUi(self)self.move(1200,320)# Press the green button in the gutter to run the script. if __name__ __main__:# 实例化应用app QApplication(sys.argv)# 实例化MyMainFormmyw MyMainForm()myw.show()myw1 MyMainForm1()myw1.show()myw.sendText.connect(myw1.deal_signal)# 启动应用程序的事件循环并等待用户交互直到应用程序关闭。sys.exit(app.exec())防止两个窗口重叠在MyMainForm1移动一下位置 self.move(1200,320) 有两个窗口建立了两个类MyMainForm与MyMainForm1它们分别继承于untitled.Ui_Form与untitled1.Ui_Form 需要注意的是untitled.py与untitled1.py都有Ui_Form为了区分Ui_Form来源不能用如下代码否者会被Ui_Form会被后面的取代 from untitled import Ui_Form from untitled1 import Ui_Form 正确书写应该是这样 import untitled import untitled1 class MyMainForm(QWidget, untitled.Ui_Form): class MyMainForm1(QWidget, untitled1.Ui_Form): 问题 在MyMainFormbutton被点击时会发出clicked信号如果用将button的clicked信号绑定槽函数在这个槽函数里面可以实现获取lineEdit的文本内容代码如下 self.pushButton.clicked.connect(self.btn_clicked) def btn_clicked(self):# 获取行编辑文本str self.lineEdit.text() MyMainForm与MyMainForm1它们是两个类没有直接关系这个槽函数在MyMainForm中不能修改MyMainForm1的label也就是不能通过如下代码 def btn_clicked(self):# 获取行编辑文本str self.lineEdit.text()self.label.setText(str) 自定义信号 如果我们可以在untitled.py的Ui_Form自定义一个信号(sendText)这个信号通过connect绑定untitled1.py的Ui_Form类函数(deal_signal)那么它们就会建立关系。 myw.sendText.connect(myw1.deal_signal) 修改代码如下 # 导入sys模块 import sys # PyQt6.QtWidgets模块中导入QApplication, QWidget from PyQt6.QtWidgets import QApplication, QWidget from PyQt6.QtCore import QObject, pyqtSignalimport untitled import untitled1class MyMainForm(QWidget, untitled.Ui_Form):sendText pyqtSignal(str)def __init__(self, parentNone):# 调用父类的构造函数super(MyMainForm, self).__init__(parent)# 调用继承Ui_Form过来的setupUi函数self.setupUi(self)self.pushButton.clicked.connect(self.btn_clicked)def btn_clicked(self):# 获取行编辑文本labelStr self.lineEdit.text()self.sendText.emit(labelStr)class MyMainForm1(QWidget, untitled1.Ui_Form):def __init__(self, parentNone):# 调用父类的构造函数super(MyMainForm1, self).__init__(parent)# 调用继承Ui_Form过来的setupUi函数self.setupUi(self)self.move(1200,320)def deal_signal(self,labelStr):self.label.setText(labelStr)# Press the green button in the gutter to run the script. if __name__ __main__:# 实例化应用app QApplication(sys.argv)# 实例化MyMainFormmyw MyMainForm()myw.show()myw1 MyMainForm1()myw1.show()myw.sendText.connect(myw1.deal_signal)# 启动应用程序的事件循环并等待用户交互直到应用程序关闭。sys.exit(app.exec())自定义信号过程 1导入 pyqtSignal类  from PyQt6.QtCore import pyqtSignal 2定义类中信号属性“str”是数据类型 sendText pyqtSignal(str) 3信号与槽绑定 myw.sendText.connect(myw1.deal_signal) 4发送信号发送的 self.sendText.emit(labelStr) 在该项目功能需求中需要获取MyMainForm的lineEdit的内容将其内容传递传递给MyMainForm1的deal_signal并在deal_signal对MyMainForm1的文本设置需要填写数类型“str”如果自定义信号不需要传递内容则不需要数据类型如下代码即可 sendText pyqtSignal() 最终实现
http://www.yutouwan.com/news/307518/

相关文章:

  • 石家庄网站建设q.479185700棒东营网络营销
  • 网站伪静态如何配置文件网站模版图片
  • 上海华亮建设集团网站使用框架开发wordpress
  • 重庆网站建设及推广公司网站建设公司的税是多少钱
  • asp成品网站广告素材网站都有哪些
  • 怎样模仿别人的网站云浮seo
  • 张家港城市建设规划局网站自己做彩票网站简单吗
  • 网站建设费在会计上怎么入账湖州市建设局网站6
  • 猪八戒网做动漫弹幕网站免费搭建手机自助网站
  • 珠海专业网站建设公司网站怎么能被百度收录
  • rp网站自动跳转图片怎么做宁波网络营销策划公司
  • 中国建设银行个人网站登录品牌建设管理办法
  • 站长之家论坛八大处网站建设
  • 好看的网站页面静态网站举例
  • 自建国际网站做电商做网站需要用什么语言开发
  • 网站素材包括哪些流量型网站
  • wordpress多站点文章调用万网可以花钱做网站
  • 一种子网站做的很好的视频广告图片在线设计网站
  • 湖北响应式网站建设设计se 网站优化
  • 北京市违法建设投诉网站首码项目推广网站
  • 网站建设公司怎么开拓业务如何做英文版网站
  • 什么学做网站来安县城乡规划建设局网站
  • 网站流量统计软件广州化妆品网站建设
  • 汉口网站制作企业简介ppt模板免费
  • 一个最简单的产品展示的asp网站应该如何做做宠物食品的网站
  • 温州建站模板搭建怎么样能够为一个网站做推广
  • 机关单位网站管理部门应建立宁波专业的网站建设团队
  • 上海专业网站制作公司黄岛网站建设哪家专业
  • wordpress外贸建站燕郊网站建设
  • 外贸流程全步骤 外贸篇北京网站推广优化公司