IsSignalConnected
This commit is contained in:
parent
39d30afef6
commit
8b9803bc40
5 changed files with 74 additions and 1 deletions
|
@ -6,6 +6,7 @@ encoding//Demo/FacePoints.py=utf-8
|
|||
encoding//Demo/FollowWindow.py=utf-8
|
||||
encoding//Demo/FramelessDialog.py=utf-8
|
||||
encoding//Demo/FramelessWindow.py=utf-8
|
||||
encoding//Demo/IsSignalConnected.py=utf-8
|
||||
encoding//Demo/Lib/Application.py=utf-8
|
||||
encoding//Demo/Lib/FramelessWindow.py=utf-8
|
||||
encoding//Demo/NativeEvent.py=utf-8
|
||||
|
|
63
Demo/IsSignalConnected.py
Normal file
63
Demo/IsSignalConnected.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Created on 2019年2月24日
|
||||
@author: Irony
|
||||
@site: https://pyqt5.com https://github.com/892768447
|
||||
@email: 892768447@qq.com
|
||||
@file: IsSignalConnected
|
||||
@description: 判断信号是否连接
|
||||
"""
|
||||
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QTextBrowser
|
||||
|
||||
|
||||
__Author__ = """By: Irony
|
||||
QQ: 892768447
|
||||
Email: 892768447@qq.com"""
|
||||
__Copyright__ = 'Copyright (c) 2019 Irony'
|
||||
__Version__ = 1.0
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Window, self).__init__(*args, **kwargs)
|
||||
layout = QVBoxLayout(self)
|
||||
self.button1 = QPushButton('已连接', self, clicked=self.doTest)
|
||||
self.button2 = QPushButton('未连接', self)
|
||||
self.retView = QTextBrowser(self)
|
||||
layout.addWidget(self.button1)
|
||||
layout.addWidget(self.button2)
|
||||
layout.addWidget(self.retView)
|
||||
|
||||
def doTest(self):
|
||||
self.retView.append("""
|
||||
# button1 clicked 是否连接: %s
|
||||
# button2 clicked 是否连接: %s
|
||||
""" % (
|
||||
self.isSignalConnected(self.button1, 'clicked()'),
|
||||
self.isSignalConnected(self.button2, 'clicked()')
|
||||
))
|
||||
|
||||
def isSignalConnected(self, obj, name):
|
||||
"""判断信号是否连接
|
||||
:param obj: 对象
|
||||
:param name: 信号名,如 clicked()
|
||||
"""
|
||||
index = obj.metaObject().indexOfMethod(name)
|
||||
if index > -1:
|
||||
method = obj.metaObject().method(index)
|
||||
if method:
|
||||
return obj.isSignalConnected(method)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
app = QApplication(sys.argv)
|
||||
w = Window()
|
||||
w.show()
|
||||
sys.exit(app.exec_())
|
|
@ -19,6 +19,7 @@
|
|||
- [背景连线动画](#17、背景连线动画)
|
||||
- [无边框圆角对话框](#18、无边框圆角对话框)
|
||||
- [调整窗口显示边框](#19、调整窗口显示边框)
|
||||
- [判断信号是否连接](#20、判断信号是否连接)
|
||||
|
||||
## 1、重启窗口Widget
|
||||
[运行 RestartWindow.py](RestartWindow.py)
|
||||
|
@ -194,4 +195,11 @@ PyQt 结合 Opencv 进行人脸检测;
|
|||
|
||||
好处在于可以减少窗口更新的次数(用途有频繁渲染的界面)
|
||||
|
||||
![ShowFrameWhenDrag](ScreenShot/ShowFrameWhenDrag.gif)
|
||||
![ShowFrameWhenDrag](ScreenShot/ShowFrameWhenDrag.gif)
|
||||
|
||||
## 20、判断信号是否连接
|
||||
[运行 IsSignalConnected.py](IsSignalConnected.py)
|
||||
|
||||
通过 `isSignalConnected` 判断是否连接
|
||||
|
||||
![IsSignalConnected](ScreenShot/IsSignalConnected.png)
|
BIN
Demo/ScreenShot/IsSignalConnected.png
Normal file
BIN
Demo/ScreenShot/IsSignalConnected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
|
@ -182,6 +182,7 @@ https://pyqt5.com 社区是专门针对PyQt5学习和提升开设的博客网站
|
|||
- [人脸特征点](Demo/FacePoints.py)
|
||||
- [使用Threading](Demo/QtThreading.py)
|
||||
- [背景连线动画](Demo/CircleLine.py)
|
||||
- [判断信号是否连接](Demo/IsSignalConnected.py)
|
||||
|
||||
# QQ群
|
||||
|
||||
|
|
Loading…
Reference in a new issue