建立连接

Posted on 2016-03-31 22:58  徐岩  阅读(162)  评论(0)    收藏  举报
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPushButton *button = new QPushButton("Quit");
    QObject::connect(button, SIGNAL(clicked()),
                     &app, SLOT(quit()));
    button->show();
    return app.exec();
}

单击Quit按钮或空格都会退出。