// 調用quit--看看Qt裏的"消息"機制
//Qt裏的很重要的特徵-信號和槽
![](http://static.javashuo.com/static/loading.gif)
#include <QApplication>
![](http://static.javashuo.com/static/loading.gif)
#include <QFont>
![](http://static.javashuo.com/static/loading.gif)
#include <QPushButton>
int main(
int argc,
char *argv[])
![](http://static.javashuo.com/static/loading.gif)
{
![](http://static.javashuo.com/static/loading.gif)
QApplication app(argc, argv);
![](http://static.javashuo.com/static/loading.gif)
QPushButton quit(
"Quit");
//建立按鈕
![](http://static.javashuo.com/static/loading.gif)
quit.resize(75, 30);
//設置按鈕尺寸
![](http://static.javashuo.com/static/loading.gif)
quit.setFont(QFont(
"Times", 18, QFont::Bold));
//設置按鈕文字字體
//這個很像DOM事件處理的addEventLisenter(事件類型,事件處理方法);
//--這裏quit按鈕的單擊信號及綁定的app程序的quit(),能夠想象成,
//單擊quit按鈕則執行程序的退出
![](http://static.javashuo.com/static/loading.gif)
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
![](http://static.javashuo.com/static/loading.gif)
quit.show();
//按鈕顯示出來
return app.exec();
![](http://static.javashuo.com/static/loading.gif)
}