title: PyQt4 Subwindow in MDI. Check which subwindow is active
body: <p>in the following executable code you can create more subwindow. But, when I switch from one subwindow to the other, I want the progrm detect which subwindow is current active. Image, we have opend two subwindow. One subwindow we call it A and the other subwindow we call it B. Both of them are already open. Subwindow A ist active, now I switch to Subwindow B. How can the class <code>Custom_Window()</code> tell me "I am here and I am currently active"?. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>import sys
  from PyQt4.QtCore import *
  from PyQt4.QtGui import *
  
  class Custom_Window(QWidget) :  
     def __init__(self, parent = None) :
        super(Custom_Window, self) .__init__(parent)
  
        # print here in this class, that itself is currently active,
        # because this window is a subwindow, so its inherits from class
        # QMdiSubWindow(). I want this subwindow itself tell me
        # whether its activated or not. BUT I don't know how to
        # solve this idea.
  
     def changeEvent(self, event):
  
        print "event", event
        print "type", type(self.parent())
        print "Status", self.parent().isActiveWindow()
  
        if event.type() == QEvent.WindowActivate:
           if self.parent().isActiveWindow():
              print "is currently active."
           else: print "I am passive"
  
  class MainWindow(QMainWindow) :
     count = 0
  
     def __init__(self, parent = None) :
        super(MainWindow, self) .__init__(parent)
        self.mdi = QMdiArea()
        self.setCentralWidget(self.mdi)
        bar = self.menuBar()
  
        file = bar.addMenu("File")
        file.addAction("New")
        file.addAction("cascade")
        file.addAction("Tiled")
        file.triggered[QAction].connect(self.windowaction)
        self.setWindowTitle("MDI demo")
  
     def windowaction(self, q) :
         custom_window = Custom_Window()
         print "triggered"
  
         if q.text() == "New" :
             MainWindow.count = MainWindow.count+1
             sub = QMdiSubWindow()
             sub.setWidget(Custom_Window() )
             sub.setWindowTitle("subwindow"+str(MainWindow.count) )
             self.mdi.addSubWindow(sub)
             sub.show()
  
         if q.text() == "cascade" :
             self.mdi.cascadeSubWindows()
  
         if q.text() == "Tiled" :
             self.mdi.tileSubWindows()
  
  def main() :
     app = QApplication(sys.argv)
     ex = MainWindow()
     ex.show()
     sys.exit(app.exec_() )
  
  if __name__ == '__main__':
     main()
  </code></pre>