#include <QApplication>
#include <QFont>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton quit("Quit");
quit.resize(75, 30);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
return app.exec();
}
1、QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
QObject::connect() is perhaps the most central feature of Qt. Note that connect() is a static function in QObject. Do not confuse it with the connect() function in the Berkeley socket library.
This connect() call establishes a one-way connection between two Qt objects (objects that inherit QObject, directly or indirectly). Every Qt object can have both signals (to send messages) and slots (to receive messages). All widgets are Qt objects, since they inherit QWidget, which in turn inherits QObject.