Ignore:
Timestamp:
Oct 2, 2008, 10:29:48 AM (16 years ago)
Author:
garnier
Message:

protection against no scene + Qapp could be now get on external app

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r850 r858  
    3030// L. Garnier
    3131
    32 //define GEANT4_QT_DEBUG
     32//#define GEANT4_QT_DEBUG
    3333
    3434#ifdef G4UI_BUILD_QT_SESSION
     
    113113  if(UI!=NULL) UI->SetSession(this);
    114114
     115  // Check if already define in external app QMainWindow
     116  bool found = false;
     117#if QT_VERSION < 0x040000
     118  // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
     119  // but if I comment them, it doesn't work...
     120  QWidgetList  *list = QApplication::allWidgets();
     121  QWidgetListIt it( *list );         // iterate over the widgets
     122  QWidget * widget;
     123  while ( (widget=it.current()) != 0 ) {  // for each widget...
     124    ++it;
     125    if ((found== false) && (widget->inherits("QMainWindow"))) {
     126      found = true;
     127    }
     128  }
     129  delete list;                      // delete the list, not the widgets
     130#else
     131  foreach (QWidget *widget, QApplication::allWidgets()) {
     132    if ((found== false) && (widget->inherits("QMainWindow"))) {
     133      found = true;
     134    }
     135  }
     136#endif
     137
     138  if (found) {
     139    G4cout        << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted" << G4endl;
     140    return ;
     141  }
    115142  fMainWindow = new QMainWindow();
    116143
Note: See TracChangeset for help on using the changeset viewer.