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. Window signal and slots not working
Servers for Qt installer are currently down

Window signal and slots not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
pyside2signal & slotevents
3 Posts 3 Posters 512 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.
  • P Offline
    P Offline
    pvlopez
    wrote on last edited by
    #1

    I'm having a problem with the closeEvent() function override in a class which is not triggering.
    This is the code I have in the main.py file:

    from mainwindow import *
    
    if __name__ == '__main__':
        app = QApplication()
        mainwindow = QMainWindow()
        window = Ui_MainWindow()
        window.setupUi(mainwindow)
        mainwindow.show()
        app.exec_()
    

    And then in another file named mainwindow.py I have:

    class Ui_MainWindow(QMainWindow):
        def setupUi(self, MainWindow):
          .......
        def retranslateUi(self, MainWindow):
             ........
        def closeEvent(self,event):
            print("Testing")
    

    But when I close the window the closeEvent() function never runs.
    I'm missing something or doing it wrong but I can't figure out what it is.
    Please help.

    JonBJ 1 Reply Last reply
    0
    • P pvlopez

      I'm having a problem with the closeEvent() function override in a class which is not triggering.
      This is the code I have in the main.py file:

      from mainwindow import *
      
      if __name__ == '__main__':
          app = QApplication()
          mainwindow = QMainWindow()
          window = Ui_MainWindow()
          window.setupUi(mainwindow)
          mainwindow.show()
          app.exec_()
      

      And then in another file named mainwindow.py I have:

      class Ui_MainWindow(QMainWindow):
          def setupUi(self, MainWindow):
            .......
          def retranslateUi(self, MainWindow):
               ........
          def closeEvent(self,event):
              print("Testing")
      

      But when I close the window the closeEvent() function never runs.
      I'm missing something or doing it wrong but I can't figure out what it is.
      Please help.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @pvlopez
      Replied in your other topic, https://forum.qt.io/topic/143047/connect-parent-window-to-child-s-close-event

      Please don't multi-post the question, do you want people to waste their time answering in two places while others are answering too?

      1 Reply Last reply
      1
      • J.HilkJ J.Hilk locked this topic on
      • J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        locked as a dublicate of
        https://forum.qt.io/topic/143047/connect-parent-window-to-child-s-close-event

        give people time to answer, usually at least 24 hours.

        This is a user driven forum, no-one is paid to be here :D


        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.

        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