Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Drop shadow not working
Forum Updated to NodeBB v4.3 + New Features

Drop shadow not working

Scheduled Pinned Locked Moved Unsolved Qt for Python
21 Posts 5 Posters 3.5k Views 2 Watching
  • 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.
  • poppypelt12P Offline
    poppypelt12P Offline
    poppypelt12
    wrote on last edited by
    #1

    In my UI i have a Main widger -> central widget -> grid-> 45 buttons and i want to apply drop shadow to all of them. I have added the libraries
    (from PySide6.QtWidgets import QApplication, QMainWindow, QDialog, QMessageBox, QGraphicsEffect, QPushButton, QGraphicsDropShadowEffect).

    I tried to apply it on a basic button BUT it didnt work there either. I made a try and exception to see if it doesent enter the drop shadow function. Here is the code in main:

    for child in self.ui.grid.findChildren(QPushButton):
    self.apply_drop_shadow(child)

    here is the function:

    def apply_drop_shadow(self, widget):
    shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
    widget.setGraphicsEffect(shadow)

    any help is GREATLY appreciated! Thank you so much ...

    Live, laugh, love

    SGaistS 1 Reply Last reply
    0
    • poppypelt12P poppypelt12

      In my UI i have a Main widger -> central widget -> grid-> 45 buttons and i want to apply drop shadow to all of them. I have added the libraries
      (from PySide6.QtWidgets import QApplication, QMainWindow, QDialog, QMessageBox, QGraphicsEffect, QPushButton, QGraphicsDropShadowEffect).

      I tried to apply it on a basic button BUT it didnt work there either. I made a try and exception to see if it doesent enter the drop shadow function. Here is the code in main:

      for child in self.ui.grid.findChildren(QPushButton):
      self.apply_drop_shadow(child)

      here is the function:

      def apply_drop_shadow(self, widget):
      shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
      widget.setGraphicsEffect(shadow)

      any help is GREATLY appreciated! Thank you so much ...

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Please write a minimal script that creates a widget with a button in it and applies the drop shadow on it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      poppypelt12P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Please write a minimal script that creates a widget with a button in it and applies the drop shadow on it.

        poppypelt12P Offline
        poppypelt12P Offline
        poppypelt12
        wrote on last edited by
        #3

        @SGaist here is what i wrote:
        import sys

        from PySide6.QtWidgets import QApplication, QMainWindow, QDialog, QMessageBox, QPushButton, QGraphicsDropShadowEffect, QTableWidget, QTableWidgetItem
        from PySide6.QtGui import QIcon, QPixmap
        from PySide6.QtCore import Qt, QSize, QPropertyAnimation, QEasingCurve, QPoint

        from ui_form import Ui_MainWindow

        import re

        class MainWindow(QMainWindow):
        def init(self, parent=None):
        super().init(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        for child in self.ui.grid.findChildren(QPushButton):
        self.apply_drop_shadow(child)

            shadow = QGraphicsDropShadowEffect()
            shadow.setBlurRadius(10)  # Adjust the blur radius as needed
            shadow.setXOffset(5)      # Adjust the X offset as needed
            shadow.setYOffset(5)      # Adjust the Y offset as needed
        
            # Apply the drop shadow effect to the button
            self.ui.legendButton.setGraphicsEffect(shadow)
            self.ui.legend.setMinimumWidth(286)
            self.ui.legendButton.setVisible(True)
            #self.apply_drop_shadow(self.ui.legendButton)
            self.ui.button_area.setGeometry(70, 0, 1800, 1080)
            self.setWindowTitle("Vital Alert")
            self.setWindowIcon(QIcon("logo.png"))
        
            self.populate_buttons()
            self.set_icons()
        
            self.showFullScreen()
        
        def apply_drop_shadow(self, widget):
            shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
            widget.setGraphicsEffect(shadow)
        

        if name == "main":
        app = QApplication(sys.argv)
        widget = MainWindow()
        widget.show()
        sys.exit(app.exec())

        Live, laugh, love

        jsulmJ 1 Reply Last reply
        0
        • poppypelt12P poppypelt12

          @SGaist here is what i wrote:
          import sys

          from PySide6.QtWidgets import QApplication, QMainWindow, QDialog, QMessageBox, QPushButton, QGraphicsDropShadowEffect, QTableWidget, QTableWidgetItem
          from PySide6.QtGui import QIcon, QPixmap
          from PySide6.QtCore import Qt, QSize, QPropertyAnimation, QEasingCurve, QPoint

          from ui_form import Ui_MainWindow

          import re

          class MainWindow(QMainWindow):
          def init(self, parent=None):
          super().init(parent)
          self.ui = Ui_MainWindow()
          self.ui.setupUi(self)
          for child in self.ui.grid.findChildren(QPushButton):
          self.apply_drop_shadow(child)

              shadow = QGraphicsDropShadowEffect()
              shadow.setBlurRadius(10)  # Adjust the blur radius as needed
              shadow.setXOffset(5)      # Adjust the X offset as needed
              shadow.setYOffset(5)      # Adjust the Y offset as needed
          
              # Apply the drop shadow effect to the button
              self.ui.legendButton.setGraphicsEffect(shadow)
              self.ui.legend.setMinimumWidth(286)
              self.ui.legendButton.setVisible(True)
              #self.apply_drop_shadow(self.ui.legendButton)
              self.ui.button_area.setGeometry(70, 0, 1800, 1080)
              self.setWindowTitle("Vital Alert")
              self.setWindowIcon(QIcon("logo.png"))
          
              self.populate_buttons()
              self.set_icons()
          
              self.showFullScreen()
          
          def apply_drop_shadow(self, widget):
              shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
              widget.setGraphicsEffect(shadow)
          

          if name == "main":
          app = QApplication(sys.argv)
          widget = MainWindow()
          widget.show()
          sys.exit(app.exec())

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @poppypelt12 Please use code tags properly, especially when posting Python code where indentation is part of the syntax!

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          poppypelt12P 1 Reply Last reply
          0
          • jsulmJ jsulm

            @poppypelt12 Please use code tags properly, especially when posting Python code where indentation is part of the syntax!

            poppypelt12P Offline
            poppypelt12P Offline
            poppypelt12
            wrote on last edited by
            #5

            @jsulm Sorry, I am a beginner haha :) i copied the code and pasted it but my program is more complex but this is the relevant part. Did i do something wrong with how i wrote the drop shadow or did i leave out a library? :(

            Live, laugh, love

            JonBJ 1 Reply Last reply
            0
            • poppypelt12P poppypelt12

              @jsulm Sorry, I am a beginner haha :) i copied the code and pasted it but my program is more complex but this is the relevant part. Did i do something wrong with how i wrote the drop shadow or did i leave out a library? :(

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @poppypelt12
              We are just asking you: when you paste code blocks, please enclose them in the forum's Code tags (the </> button). This will post all the code literally, including spacing, which is so vital in Python.

              poppypelt12P 1 Reply Last reply
              0
              • JonBJ JonB

                @poppypelt12
                We are just asking you: when you paste code blocks, please enclose them in the forum's Code tags (the </> button). This will post all the code literally, including spacing, which is so vital in Python.

                poppypelt12P Offline
                poppypelt12P Offline
                poppypelt12
                wrote on last edited by
                #7

                @JonB Okay, here is the code with the forums code tags ^^

                <class MainWindow(QMainWindow):
                def init(self, parent=None):
                super().init(parent)
                self.ui = Ui_MainWindow()
                self.ui.setupUi(self)

                    self.room_instance = Room(None, None, None)
                    self.data=self.room_instance.read_data_from_file("rooms.json")
                
                    self.ui.settings.clicked.connect(self.showSettings)
                    self.ui.panels.clicked.connect(self.showPanels)
                    self.ui.legendButton.clicked.connect(self.legend_change_size)
                
                    for child in self.ui.grid.findChildren(QPushButton):
                        self.apply_drop_shadow(child)
                
                    shadow = QGraphicsDropShadowEffect()
                    shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                    shadow.setXOffset(5)      # Adjust the X offset as needed
                    shadow.setYOffset(5)      # Adjust the Y offset as needed
                
                    # Apply the drop shadow effect to the button
                    self.ui.legendButton.setGraphicsEffect(shadow)
                    self.ui.legend.setMinimumWidth(286)
                    self.ui.legendButton.setVisible(True)
                    #self.apply_drop_shadow(self.ui.legendButton)
                    self.ui.button_area.setGeometry(70, 0, 1800, 1080)
                    self.setWindowTitle("Vital Alert")
                    self.setWindowIcon(QIcon("logo.png"))
                
                    self.populate_buttons()
                    self.set_icons()
                
                    self.showFullScreen()
                
                def apply_drop_shadow(self, widget):
                    shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
                    widget.setGraphicsEffect(shadow)
                

                />

                Live, laugh, love

                jsulmJ J.HilkJ 2 Replies Last reply
                0
                • poppypelt12P poppypelt12

                  @JonB Okay, here is the code with the forums code tags ^^

                  <class MainWindow(QMainWindow):
                  def init(self, parent=None):
                  super().init(parent)
                  self.ui = Ui_MainWindow()
                  self.ui.setupUi(self)

                      self.room_instance = Room(None, None, None)
                      self.data=self.room_instance.read_data_from_file("rooms.json")
                  
                      self.ui.settings.clicked.connect(self.showSettings)
                      self.ui.panels.clicked.connect(self.showPanels)
                      self.ui.legendButton.clicked.connect(self.legend_change_size)
                  
                      for child in self.ui.grid.findChildren(QPushButton):
                          self.apply_drop_shadow(child)
                  
                      shadow = QGraphicsDropShadowEffect()
                      shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                      shadow.setXOffset(5)      # Adjust the X offset as needed
                      shadow.setYOffset(5)      # Adjust the Y offset as needed
                  
                      # Apply the drop shadow effect to the button
                      self.ui.legendButton.setGraphicsEffect(shadow)
                      self.ui.legend.setMinimumWidth(286)
                      self.ui.legendButton.setVisible(True)
                      #self.apply_drop_shadow(self.ui.legendButton)
                      self.ui.button_area.setGeometry(70, 0, 1800, 1080)
                      self.setWindowTitle("Vital Alert")
                      self.setWindowIcon(QIcon("logo.png"))
                  
                      self.populate_buttons()
                      self.set_icons()
                  
                      self.showFullScreen()
                  
                  def apply_drop_shadow(self, widget):
                      shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
                      widget.setGraphicsEffect(shadow)
                  

                  />

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @poppypelt12 said in Drop shadow not working:

                  here is the code with the forums code tags

                  Better, but still not correct

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  poppypelt12P 1 Reply Last reply
                  0
                  • poppypelt12P poppypelt12

                    @JonB Okay, here is the code with the forums code tags ^^

                    <class MainWindow(QMainWindow):
                    def init(self, parent=None):
                    super().init(parent)
                    self.ui = Ui_MainWindow()
                    self.ui.setupUi(self)

                        self.room_instance = Room(None, None, None)
                        self.data=self.room_instance.read_data_from_file("rooms.json")
                    
                        self.ui.settings.clicked.connect(self.showSettings)
                        self.ui.panels.clicked.connect(self.showPanels)
                        self.ui.legendButton.clicked.connect(self.legend_change_size)
                    
                        for child in self.ui.grid.findChildren(QPushButton):
                            self.apply_drop_shadow(child)
                    
                        shadow = QGraphicsDropShadowEffect()
                        shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                        shadow.setXOffset(5)      # Adjust the X offset as needed
                        shadow.setYOffset(5)      # Adjust the Y offset as needed
                    
                        # Apply the drop shadow effect to the button
                        self.ui.legendButton.setGraphicsEffect(shadow)
                        self.ui.legend.setMinimumWidth(286)
                        self.ui.legendButton.setVisible(True)
                        #self.apply_drop_shadow(self.ui.legendButton)
                        self.ui.button_area.setGeometry(70, 0, 1800, 1080)
                        self.setWindowTitle("Vital Alert")
                        self.setWindowIcon(QIcon("logo.png"))
                    
                        self.populate_buttons()
                        self.set_icons()
                    
                        self.showFullScreen()
                    
                    def apply_drop_shadow(self, widget):
                        shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
                        widget.setGraphicsEffect(shadow)
                    

                    />

                    J.HilkJ Online
                    J.HilkJ Online
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #9

                    @poppypelt12
                    6343ea52-0d90-4681-9e9d-a90a09230d40-image.png


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    poppypelt12P 1 Reply Last reply
                    0
                    • J.HilkJ J.Hilk

                      @poppypelt12
                      6343ea52-0d90-4681-9e9d-a90a09230d40-image.png

                      poppypelt12P Offline
                      poppypelt12P Offline
                      poppypelt12
                      wrote on last edited by
                      #10

                      @J-Hilk

                      import sys
                      
                      from PySide6.QtWidgets import QApplication, QMainWindow, QDialog, QMessageBox, QPushButton, QGraphicsDropShadowEffect, QTableWidget, QTableWidgetItem
                      from PySide6.QtGui import QIcon, QPixmap
                      from PySide6.QtCore import Qt, QSize, QPropertyAnimation, QEasingCurve, QPoint
                      
                      from ui_form import Ui_MainWindow
                      from add_room import AddRoomDialog
                      from room import Room
                      from settings import Settings
                      from panels import Panels
                      
                      import re
                      
                      class MainWindow(QMainWindow):
                          def __init__(self, parent=None):
                              super().__init__(parent)
                              self.ui = Ui_MainWindow()
                              self.ui.setupUi(self)
                      
                              self.ui.legendButton.clicked.connect(self.legend_change_size)
                      
                              for child in self.ui.grid.findChildren(QPushButton):
                                  self.apply_drop_shadow(child)
                      
                              shadow = QGraphicsDropShadowEffect()
                              shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                              shadow.setXOffset(5)      # Adjust the X offset as needed
                              shadow.setYOffset(5)      # Adjust the Y offset as needed
                      
                              # Apply the drop shadow effect to the button
                              self.ui.legendButton.setGraphicsEffect(shadow)
                              self.ui.legend.setMinimumWidth(286)
                              self.ui.legendButton.setVisible(True)
                              #self.apply_drop_shadow(self.ui.legendButton)
                              self.ui.button_area.setGeometry(70, 0, 1800, 1080)
                              self.setWindowTitle("Vital Alert")
                              self.setWindowIcon(QIcon("logo.png"))
                      
                              self.populate_buttons()
                              self.set_icons()
                      
                              self.showFullScreen()
                      
                          def apply_drop_shadow(self, widget):
                              shadow = QGraphicsDropShadowEffect(blurRadius=5, xOffset=10, yOffset=10)
                              widget.setGraphicsEffect(shadow)
                      
                      

                      thank you for the inpot

                      Live, laugh, love

                      1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @poppypelt12 said in Drop shadow not working:

                        here is the code with the forums code tags

                        Better, but still not correct

                        poppypelt12P Offline
                        poppypelt12P Offline
                        poppypelt12
                        wrote on last edited by
                        #11

                        @jsulm Could you please tell me what you think i did wrong? It is very important to me..! I think you are the only one who can help me with this...

                        Live, laugh, love

                        jsulmJ 1 Reply Last reply
                        0
                        • poppypelt12P poppypelt12

                          @jsulm Could you please tell me what you think i did wrong? It is very important to me..! I think you are the only one who can help me with this...

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @poppypelt12 Did you actually check whether self.ui.grid.findChildren(QPushButton) returned anything?

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          poppypelt12P 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @poppypelt12 Did you actually check whether self.ui.grid.findChildren(QPushButton) returned anything?

                            poppypelt12P Offline
                            poppypelt12P Offline
                            poppypelt12
                            wrote on last edited by
                            #13

                            @jsulm I dont know, but I tried doing it in another project on a regular single button, and it didn't work in there either, does it work for you?

                            Live, laugh, love

                            jsulmJ 1 Reply Last reply
                            0
                            • poppypelt12P poppypelt12

                              @jsulm I dont know, but I tried doing it in another project on a regular single button, and it didn't work in there either, does it work for you?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @poppypelt12 Well, without ui_form I can't run your script.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              poppypelt12P 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @poppypelt12 Well, without ui_form I can't run your script.

                                poppypelt12P Offline
                                poppypelt12P Offline
                                poppypelt12
                                wrote on last edited by
                                #15

                                @jsulm but can you add a drop shadow at all to any button? please if i cant figure this out i will cry :(

                                Live, laugh, love

                                jsulmJ 2 Replies Last reply
                                0
                                • poppypelt12P poppypelt12

                                  @jsulm but can you add a drop shadow at all to any button? please if i cant figure this out i will cry :(

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @poppypelt12 You were asked to write MINIMAL script. You did not.
                                  Here, I did it for you:

                                  import sys
                                  
                                  from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QGraphicsDropShadowEffect
                                  
                                  class MainWindow(QMainWindow):
                                      def __init__(self, parent=None):
                                          super().__init__(parent)
                                  
                                          shadow = QGraphicsDropShadowEffect()
                                          shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                                          shadow.setXOffset(5)      # Adjust the X offset as needed
                                          shadow.setYOffset(5)      # Adjust the Y offset as needed
                                  
                                          self.button = QPushButton(self)
                                          self.button.setGraphicsEffect(shadow)
                                  
                                  if __name__ == '__main__':
                                      app = QApplication()
                                  
                                      mainWindow = MainWindow()
                                      mainWindow.show()
                                  
                                      app.exec()
                                  

                                  And no, I don't see any drop shadow.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  poppypelt12P 1 Reply Last reply
                                  0
                                  • poppypelt12P poppypelt12

                                    @jsulm but can you add a drop shadow at all to any button? please if i cant figure this out i will cry :(

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    @poppypelt12 This works:

                                    import sys
                                    
                                    from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QGraphicsDropShadowEffect
                                    
                                    class MainWindow(QMainWindow):
                                        def __init__(self, parent=None):
                                            super().__init__(parent)
                                    
                                            self.shadow = QGraphicsDropShadowEffect()
                                            self.shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                                            self.shadow.setXOffset(5)      # Adjust the X offset as needed
                                            self.shadow.setYOffset(5)      # Adjust the Y offset as needed
                                    
                                            self.button = QPushButton(self)
                                            self.button.setGraphicsEffect(self.shadow)
                                    
                                    if __name__ == '__main__':
                                        app = QApplication()
                                    
                                        mainWindow = MainWindow()
                                        mainWindow.show()
                                    
                                        app.exec()
                                    

                                    Do you know why? Hint: think about life time of "shadow" in the previous code.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    poppypelt12P 2 Replies Last reply
                                    2
                                    • jsulmJ jsulm

                                      @poppypelt12 You were asked to write MINIMAL script. You did not.
                                      Here, I did it for you:

                                      import sys
                                      
                                      from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QGraphicsDropShadowEffect
                                      
                                      class MainWindow(QMainWindow):
                                          def __init__(self, parent=None):
                                              super().__init__(parent)
                                      
                                              shadow = QGraphicsDropShadowEffect()
                                              shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                                              shadow.setXOffset(5)      # Adjust the X offset as needed
                                              shadow.setYOffset(5)      # Adjust the Y offset as needed
                                      
                                              self.button = QPushButton(self)
                                              self.button.setGraphicsEffect(shadow)
                                      
                                      if __name__ == '__main__':
                                          app = QApplication()
                                      
                                          mainWindow = MainWindow()
                                          mainWindow.show()
                                      
                                          app.exec()
                                      

                                      And no, I don't see any drop shadow.

                                      poppypelt12P Offline
                                      poppypelt12P Offline
                                      poppypelt12
                                      wrote on last edited by
                                      #18

                                      @jsulm Then pleaese how can i make a drop shadow? i searched everywhere on the internet but there is not much info on this and most of it is outdated, i really need your help

                                      Live, laugh, love

                                      1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @poppypelt12 This works:

                                        import sys
                                        
                                        from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QGraphicsDropShadowEffect
                                        
                                        class MainWindow(QMainWindow):
                                            def __init__(self, parent=None):
                                                super().__init__(parent)
                                        
                                                self.shadow = QGraphicsDropShadowEffect()
                                                self.shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                                                self.shadow.setXOffset(5)      # Adjust the X offset as needed
                                                self.shadow.setYOffset(5)      # Adjust the Y offset as needed
                                        
                                                self.button = QPushButton(self)
                                                self.button.setGraphicsEffect(self.shadow)
                                        
                                        if __name__ == '__main__':
                                            app = QApplication()
                                        
                                            mainWindow = MainWindow()
                                            mainWindow.show()
                                        
                                            app.exec()
                                        

                                        Do you know why? Hint: think about life time of "shadow" in the previous code.

                                        poppypelt12P Offline
                                        poppypelt12P Offline
                                        poppypelt12
                                        wrote on last edited by
                                        #19

                                        @jsulm Oh my god thank you so much!

                                        Live, laugh, love

                                        1 Reply Last reply
                                        0
                                        • jsulmJ jsulm

                                          @poppypelt12 This works:

                                          import sys
                                          
                                          from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QGraphicsDropShadowEffect
                                          
                                          class MainWindow(QMainWindow):
                                              def __init__(self, parent=None):
                                                  super().__init__(parent)
                                          
                                                  self.shadow = QGraphicsDropShadowEffect()
                                                  self.shadow.setBlurRadius(10)  # Adjust the blur radius as needed
                                                  self.shadow.setXOffset(5)      # Adjust the X offset as needed
                                                  self.shadow.setYOffset(5)      # Adjust the Y offset as needed
                                          
                                                  self.button = QPushButton(self)
                                                  self.button.setGraphicsEffect(self.shadow)
                                          
                                          if __name__ == '__main__':
                                              app = QApplication()
                                          
                                              mainWindow = MainWindow()
                                              mainWindow.show()
                                          
                                              app.exec()
                                          

                                          Do you know why? Hint: think about life time of "shadow" in the previous code.

                                          poppypelt12P Offline
                                          poppypelt12P Offline
                                          poppypelt12
                                          wrote on last edited by
                                          #20

                                          @jsulm i am very thankful johann

                                          Live, laugh, love

                                          jsulmJ 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