Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. make qgraphicsdropshadow effect work on transparent widget colors
Forum Updated to NodeBB v4.3 + New Features

make qgraphicsdropshadow effect work on transparent widget colors

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 148 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shahzaib Hassan
    wrote on last edited by Shahzaib Hassan
    #1

    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
    d967f093-244c-4477-b2b1-53a065bb30fd-image.png
    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()
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved