[Qt-interest] How to quit Qt app after browser opening?
Nikos Chantziaras
realnc at arcor.de
Wed Jun 1 15:10:11 CEST 2011
On 06/01/2011 03:36 PM, 程梁 wrote:
> Hi, there! I tried to develop an application to open the default web
> site using Qt.
>
> I use QDesktopServices::openUrl(theURL); to do this. But the problem is
> when my default browser opens, the Qt application will not quit. What I
> want to get is, after the browser opens, this Qt application quit
> automatically. But I did not find how to do this. I tried this code:
> if(QDesktopServices::openURL())
> qApp->quit();
> but it doesn't work. Here is my whole code, could you tell me how to
> solve this problem?
>
> if(QDesktopServices::openUrl(QUrl(serverURL, QUrl::TolerantMode))) {
>
> app.quit();
app.quit() is only useful after the application has started (meaning
after app.exec()). So in your case, simply replace app.quit() with
return 0.
More information about the Qt-interest-old
mailing list