title: How to find active QMainWindow instance?
body: <p>Greetings all,</p>
  
  <p>In my QT Application I have several QMainWindow instances.
  I keep track of opended QWindow objects in a Application Context object;</p>
  
  <p>At onepoint ,when a Menu item is clicked , I want to go through all this QWindows and check which Window is active and
  execute some operations.</p>
  
  <p>Please refer to following code snippet :</p>
  
  <pre><code>//Just a confirmation dialog
  QMessageBox msgBox(this-&gt;getMainWindow());
  msgBox.setText("This will discard existing project");
  msgBox.setInformativeText("All Contour data and Volume data will be discarded");
  msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
  msgBox.setDefaultButton(QMessageBox::Ok);
  if(msgBox.exec()==QMessageBox::Cancel)
  {
   return
  }
  
  
  //This is where I check the active window.
  
  QList&lt;MainWindow*&gt; lst= applicationContext.getOpendedWindows();
  
  for(i=0;i&lt;lst.size();i++)
  {
    MainWindow *win=lst.value(i);
  
     //Check if this is the active window
     if(win.isActive()){  // tried (win==QApplication::activeWindow()) also
        //DO SOMETHING with 'win' object
     }
    }
  }
  </code></pre>
  
  <p>This check works fine when I dont show the confirmation dialog before the check.
  That is, when I comment out the line 'msgBox.exe()' I can find an active window from the list.</p>
  
  <p>Does the displaying of QMessageBox change the focused window?</p>
  
  <p>Any tips on this?</p>
  
  <p>Thanks in advance,</p>
  
  <p>umanga</p>