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 6.3k 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.
  • 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
                      • poppypelt12P poppypelt12

                        @jsulm i am very thankful johann

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

                        @poppypelt12 It is common mistake to declare a local variable which is destroyed as soon as it goes out of scope. Just be careful when declaring variables and think about scope and life time of objects.

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

                        1 Reply Last reply
                        1

                        • Login

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