[Qt-interest] return to command line but the GUI is still alive

Colin S. Miller no-spam-thank-you at csmiller.demon.co.uk
Sun Jan 24 21:12:39 CET 2010


Forest Yang wrote:
> Thanks ! I was too curious about the techniques to forget this simple one.
> 
> Just for curious, can we implement the similar thing without "&" ? I
> saw this effect from a TCL/TK program and also Acrobat Reader.
> 
> One good future usage would be like Acrobat Reader, if there are files
> opened, or one acroreader alive, when execute
> 
> $ acroread file.pdf
> 
> It just open a new tab in the reader and return to shell, even you did
> not put a "&" at the end
> 
> 
Forest,
this is the normal way of doing this.
The child should be able to read stdin
after forking, but I've never tried.

However, the child process is no longer considered
a (grand)child of the shell that invoked it.

HTH,
Colin S. Miller


int main(int argc, char** argv)
{
   pid_t pid;

   pid=fork();
   if (pid==0)
   {
     /* we're the child */
     QApplication qapp(argc, argv);
     MainWindow mainWindow;
     mainWindow.show();

     qapp.setMainWidget(&mainWindow);
     qapp.exec();
   }
}




More information about the Qt-interest-old mailing list