[Qt-interest] replace QCoreApplication by QApplication?

Alexander Poddey alexander.poddey at gmx.net
Sun Aug 30 11:01:39 CEST 2009


Hi all,

is it possible to somehow purge or quit a QCoreApplication and start init a 
QApplication in the same main?

i start with a qcore application, hande commandline options, thereby find out 
if a gui should be started. if this is the case, I need 'switch' to a 
QApplication which opens a window.

code example:
----------------------------

int ain(int argc, char *argv[])
{
  QCoreApplication app(argc, argv);

  //=== extract command line options & start processing
  //    non-gui commands
  LeC	ommand lc;
  lc.process(app); //processes the command line, 
  //lets LeParam.tgui() return 'true' 
  
  //=== try to start gui if needed
  if(LeParam.tgui()){
	//GET RID OF QCoreApplication ?
    QApplication appgui(argc, argv);
    
    
    MainWindow window;
    window.resize(640, 480);
    window.show();
    
    
    appgui.exec();
  }//if(LeParam.tgui())
}

-----------------------------
the code compiles and run, the window however does show up only if i purge the 
QCoreApplication dependent lines.
I guess this is, because one can either use QCoreApplication or QApplication 
at the same time. 
Any ideas how to use them in a sequence?

thx 
alex



More information about the Qt-interest-old mailing list