9
我試圖創建一個退出按鈕,它正確關閉了我在QT中所做的GUI。我曾嘗試通過以下方式這樣做:如何在qt中創建正確的退出按鈕
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int window_width = QApplication::desktop()->width();
int window_height = QApplication::desktop()->height();
MainWindow w;
QPushButton * quit_btn = new QPushButton;
quit_btn->setParent(w.centralWidget());
quit_btn->setGeometry(window_width-50,12,32,32);
QObject::connect(quit_btn,SIGNAL(clicked()),qApp,SLOT(quit()));
w.resize(window_width,window_height);
w.show();
return a.exec();
}
不幸的是,當我按下按鈕,調試器提供了一個錯誤:
Invalid address specified to RtlFreeHeap(003E0000, 0028F950)
可有人點我在正確的方向?