当前位置:网站首页>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():
边栏推荐
- Class常量池与运行时常量池
- Confirm the future development route! Digital economy, digital transformation, data This meeting is very important
- idea gradle lombok 报错集锦
- 史上最全学习率调整策略lr_scheduler
- Index of MySQL
- 2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
- [MySQL] row sorting in MySQL
- Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
- 2022电工杯A题高比例风电电力系统储能运行及配置分析思路
- 如何检测mysql代码运行是否出现死锁+binlog查看
猜你喜欢

链表面试常见题

Free PHP online decryption tool source code v1.2

NoSQL之Redis配置与优化

Arduino droplet detection

Adaptive non European advertising retrieval system amcad

What is the experience of maintaining Wanxing open source vector database

Some thoughts on cross end development of kbone and applet

Force buckle ----- path sum III

QT opens a file and uses QFileDialog to obtain the file name, content, etc

Simple implementation of AVL tree insertion and verification operations
随机推荐
ABAP dynamic inner table grouping cycle
NoSQL之Redis配置与优化
What is Ba? How about Ba? What is the relationship between Ba and Bi?
2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
本机mysql
Confirm the future development route! Digital economy, digital transformation, data This meeting is very important
ABAP 动态内表分组循环
[security attack and Defense] how much do you know about serialization and deserialization?
Machine learning notes - bird species classification using machine learning
Some thoughts on cross end development of kbone and applet
My brave way to line -- elaborate on what happens when the browser enters the URL
2022年上半年HIT行业TOP50
如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
MySQL的存储引擎
Unity3D在一建筑GL材料可以改变颜色和显示样本
三重半圆环进度条,直接拿去就能用
web服务性能监控方案
用头像模仿天狗食月
Implementation of map and set