[英]Hide the app from screen but not from taskbar
我想从屏幕上隐藏应用程序,而不是从任务栏上隐藏应用程序,我尝试这样做:
app = QtWidgets.QApplication([])
w = QtWidgets.QWidget()
w.show()
w.resize(0, 0)
但这不起作用,知道吗?
app = QtWidgets.QApplication([])
w = QtWidgets.QWidget()
w.showMinimized()
我使用QMainWindow而不是QWidget ,然后覆盖了focusInEvent和focusOutEvent事件。
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtCore import Qt
from sys import argv, exit
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setFocusPolicy(Qt.StrongFocus)
def focusInEvent(self, event):
print('focusInEvent')
self.setWindowTitle('focusInEvent')
self.showMinimized()
def focusOutEvent(self, event):
print('focusOutEvent')
self.setWindowTitle('focusOutEvent')
# self.showMinimized()
if __name__ == '__main__':
app = QApplication([])
w = Window()
w.showMinimized()
exit(app.exec_())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.