Greetings all,
In my QT Application I have several QMainWindow instances. I keep track of opended QWindow objects in a Application Context object;
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.
Please refer to following code snippet :
//Just a confirmation dialog
QMessageBox msgBox(this->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<MainWindow*> lst= applicationContext.getOpendedWindows();
for(i=0;i<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
}
}
}
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.
Does the displaying of QMessageBox change the focused window?
Any tips on this?
Thanks in advance,
umanga