当前位置:网站首页>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():
边栏推荐
猜你喜欢
10 ways of interface data security assurance

A 股指数成分数据 API 数据接口

自适应非欧表征广告检索系统AMCAD

Machine learning notes - bird species classification using machine learning

Kbone与小程序跨端开发的一些思考

Some common software related

Some thoughts on cross end development of kbone and applet

Class constant pool and runtime constant pool

Food Chem|深度学习根据成分声明准确预测食品类别和营养成分

Operational amplifier application summary 1
随机推荐
First understand the principle of network
本机mysql
NoSQL之Redis配置与优化
Probability formula
The JSON format of the international area code of the mobile phone number is obtained with PHP
Class constant pool and runtime constant pool
List interview common questions
web服务性能监控方案
A 股指数成分数据 API 数据接口
【安全攻防】序列化與反序列,你了解多少?
golang 压缩和解压zip文件
浅谈网络安全之文件上传
什么是 BA ?BA怎么样?BA和BI是什么关系?
AVL树插入操作与验证操作的简单实现
Redis configuration and optimization of NoSQL
. Net interface can be implemented by default
使用 TiDB Lightning 恢复 GCS 上的备份数据
红米k40s root玩机笔记
vim —- 自己主动的按钮indent该命令「建议收藏」
Redis源码学习(31),字典学习,dict.c(一)