Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.15.0
-
None
-
Kubuntu 20.04
Description
I can not create a window with transparent background.
Here is a minimal example that displays a circle (in Python):
import sys from PyQt5.QtCore import Qt from PyQt5.QtGui import QPainter, QBrush from PyQt5.QtWidgets import QDialog, QApplicationWIDTH=400 HEIGHT=400class MyWindow(QDialog): def __init__(self): super().__init__() self.setModal(True) self.setWindowOpacity(0.5) self.setStyleSheet('background: transparent; background-color: none; opacity: 0.5;') self.setAttribute(Qt.WA_TranslucentBackground, True) self.setWindowFlags(Qt.Window | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_OpaquePaintEvent, False) #self.setAttribute(Qt.WA_PaintOnScreen) self.setMinimumWidth(WIDTH) self.setMinimumHeight(HEIGHT) self.setMaximumWidth(WIDTH) self.setMaximumHeight(HEIGHT) def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.setBrush(QBrush(Qt.gray, Qt.SolidPattern)) painter.drawEllipse(0, 0, WIDTH, HEIGHT)def main(): app = QApplication(sys.argv) win = MyWindow() win.show() sys.exit(app.exec_())
As you can see I tried many things (setWindowOpacity, Qt.WA_NoSystemBackground, Qt.WA_OpaquePaintEvent, etc), but the black background is still visible.
On my other other computer which runs Manjaro it works well, but not on my current, which runs Kubuntu 20.04. I tried both with PyQt 5.15 and 5.12 (the version used by KDE).