cpp文件
#include <QApplication> #include <QPushButton> #include <QMessageBox> int main(int argv,char *argc[]) { QApplication app(argv,argc);//管理QtGUI程序包括程序初始化、事件响应机制的循环、程序销毁等 QPushButton button(QObject::tr("click")); button.show(); QMessageBox msg; msg.setText("Hello world"); QObject::connect(&button,SIGNAL(clicked()),&msg,SLOT(show()));//信号与槽(不求甚解) return app.exec();//开始事件驱动循环 }