make qgraphicsdropshadow effect work on transparent widget colors
Unsolved
General and Desktop
-
Hi, i made a class that takes a window and draws a glowing area on it. The trick i used is to make a QFrame, and apply a qgraphicsdropshadow effect on it. And setting the offset to -glow_width and -glow_height. this makes a glowing area and works how ever the frame interepts with other widgets on the screen
I tried to make the frame color transparent, but that just makes the glow effect invisible. ( Note that the color_to_rgb() function converts a color or hex color to RGBA format. )Heres my code for the class:
class GlowBox: def __init__(self, master, glow_color='green', corner_radius=5, blur_radius=10, width=50, height=50): glow_color = color_to_rgb(glow_color) self._f = QFrame(master ) self._f.setFixedSize(width,height) self._f.setStyleSheet(f''' QFrame {{ border-radius: {corner_radius}; }} ''') self.attributes_width = width self.attributes_height = height blur_effect = QGraphicsDropShadowEffect() blur_effect.setBlurRadius(blur_radius) blur_effect.setOffset(-width,-height) blur_effect.setColor(QColor(glow_color[0],glow_color[1],glow_color[2],glow_color[3]) ) self._f.setGraphicsEffect(blur_effect) def place(self, x,y): self._f.move(x+self.attributes_width,y+self.attributes_height) self._f.show()