我試圖使用qApp-> exit()退出應用程序並關閉UI。但是我失敗了,在qApp-> exit()執行後,UI仍然存在。任何人都可以幫忙弄清楚爲什麼?非常感謝。QT:如何退出應用程序並關閉UI
#include "clsDownloadUpdateList.h"
#include <QApplication>
#include <qtranslator.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
translator.load("en-CN_upgrader");
qApp->installTranslator(&translator);
clsDownloadUpdateList w;
w.show();
return a.exec();
}
clsDownloadUpdateList::clsDownloadUpdateList(QWidget *parent) :
QMainWindow(parent),
_state(STOP),
ui(new Ui::clsDownloadUpdateList)
{
ui->setupUi(this);
this->setWindowTitle("GCS Upgrader");
// other code
// here comes the code to exit application
qApp->exit();
// but the UI is still there.
}
你似乎調用'qApp- >在'a.exec()'前退出()'。 – thuga