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
QtWS25 Last Chance

Window signal and slots not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
pyside2signal & slotevents
3 Posts 3 Posters 448 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 17 Feb 2023, 14:45 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.

    J 1 Reply Last reply 17 Feb 2023, 14:55
    0
    • P pvlopez
      17 Feb 2023, 14:45

      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.

      J Offline
      J Offline
      JonB
      wrote on 17 Feb 2023, 14:55 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 J.Hilk locked this topic on 17 Feb 2023, 14:57
      • J Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 17 Feb 2023, 14:58 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

        1/3

        17 Feb 2023, 14:45

        • Login

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