1
我一直在使用PyQt5(v.5.7)编写用Python编写的截图应用程序(v.3.5),但我一直在MacOs上开发它。该应用程序在Mac上按照预期运行,但是当我将回购程序拖到Windows 10机器上时,我无法让应用程序正常呈现。PyQt5透明窗口错误?
基本上我想要一个全屏透明窗口,这里是我使用的代码。事实上,没有任何东西可以呈现。 (Qt
从QtCore
进口)
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground)
#Maximize the window
self.showFullScreen()
#Render the window
self.activateWindow()
self.setFocus()
self.show()
当我注释掉self.setAttribute(Qt.WA_TranslucentBackground)
它实际上将呈现(但与灰色十岁上下的背景)。
我试过从setWindowFlags()
删除self.windowFlags()
无济于事(如在this答案中所见)。
也试过它没有self.setFocus()
和self.activateWindow()
这是一个错误?或者我在这里做错了什么。
任何帮助,将不胜感激。
尝试使用'self.setWindowOpacity(0.5)的''而不是self.setAttribute(Qt.WA_TranslucentBackground)'和调整不透明度通缉。 你可以看看[这里](http://stackoverflow.com/questions/37530276/transparent-widgets-inside-transparent-frame-pyqt5)了解更多详情。从我的理解你想要完整的背景透明和可见的部件? – SyedElec