当前位置:网站首页>pyqt5 失焦 监听无操作 定时器
pyqt5 失焦 监听无操作 定时器
2022-07-06 21:36:00 【AI视觉网奇】
pyqt5 失焦 无操作监听
以下内容转自:
如何捕获PyQt5 QMainWindow失去焦点-python黑洞网
timer可以更新ui。
class MainUi(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.init_ui()
self.setFocus()
QtWidgets.qApp.focusChanged.connect(self.on_focusChanged)
@QtCore.pyqtSlot("QWidget*", "QWidget*")
def on_focusChanged(self, old, now):
if now == None:
print(f"\nwindow lost focus: {self.isActiveWindow()}",time.strftime('%Y-%m-%d %H:%M:%S'))
# self.setWindowState(QtCore.Qt.WindowMinimized)
self.loss_start = time.time() # 记录开始时间
self.timer.start(1000*5) # 设置计时间隔并启动,1秒
def lose_focus(self):
if not self.isActiveWindow():
边栏推荐
猜你喜欢

Hisilicon 3559 universal platform construction: RTSP real-time playback support

机械臂速成小指南(十):可达工作空间

概率论公式

Kalman filter-1

Do you choose pandas or SQL for the top 1 of data analysis in your mind?

2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析

Construction of Hisilicon universal platform: color space conversion YUV2RGB

史上最全MongoDB之Mongo Shell使用

Some thoughts on cross end development of kbone and applet

2022年上半年HIT行业TOP50
随机推荐
10 ways of interface data security assurance
Introduction to opensea platform developed by NFT trading platform (I)
手机号国际区号JSON格式另附PHP获取
2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
QT opens a file and uses QFileDialog to obtain the file name, content, etc
2022电工杯A题高比例风电电力系统储能运行及配置分析思路
My brave way to line -- elaborate on what happens when the browser enters the URL
Preprocessing - interpolation
C task expansion method
【安全攻防】序列化与反序列,你了解多少?
Binary, octal, hexadecimal
数据的存储
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
Tflite model transformation and quantification
Baidu map JS development, open a blank, bmapgl is not defined, err_ FILE_ NOT_ FOUND
链表面试常见题
Force buckle ----- path sum III
Kotlin Android 环境搭建
golang 压缩和解压zip文件
二叉搜索树的实现