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. call function when close second windows
Qt 6.11 is out! See what's new in the release blog

call function when close second windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 188 Views 1 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.
  • N Offline
    N Offline
    Nezox212
    wrote on last edited by
    #1
    class Ui_first1(object):
     def setupUi(self, first1):
         first1.setObjectName("first1")
         first1.resize(380, 249)
         
         self.label = QtWidgets.QLabel(first1)
         self.label.setGeometry(QtCore.QRect(160, 80, 191, 71))
         self.label.setObjectName("label")
    
         self.retranslateUi(first1)
         QtCore.QMetaObject.connectSlotsByName(first1)
    
     def retranslateUi(self, first1):
         _translate = QtCore.QCoreApplication.translate
         first1.setWindowTitle(_translate("first1", "Form"))
         self.label.setText(_translate("first1", "first windows"))
    
     
    
    
    class Ui_second2(object):
     def setupUi(self, second2):
         second2.setObjectName("second2")
         second2.resize(394, 300)
         self.label = QtWidgets.QLabel(second2)
         self.label.setGeometry(QtCore.QRect(50, 120, 191, 71))
         self.label.setObjectName("label")
         app.aboutToQuit.connect(self.closeEvent) # as I understand its bind close button
    
         self.retranslateUi(second2)
         QtCore.QMetaObject.connectSlotsByName(second2)
    
     def retranslateUi(self, second2):
         _translate = QtCore.QCoreApplication.translate
         second2.setWindowTitle(_translate("second2", "Form"))
         self.label.setText(_translate("second2", "second windows"))
    
     # need print text when user close second windows, but print when close firs windows
     def closeEvent(self,):
         print("close")
    

    When a close second windows nothing happens, but when I close all windows and the function is called. I need to call function when close only second windows. How to fix it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You are modifying the wrong part of the code. The Ui_XXX classes are generated based on the .ui file you created with designer. They are not even widgets. You need to modify the widget code that uses the Ui_XXX classes.

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

      1 Reply Last reply
      2

      • Login

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