重点知识已近在代码里注释... 请仔细看代码 本文原创 转载请保留此链接 http://blog.csdn.net/siren0203 头文件 input .h #ifndef INPUT_H #define INPUT_H #include <QObject> #include <QDialog> class QPushButton; class QLabel; class InputDlg:public QDialog{ Q_OBJECT public: InputDlg(); private: QPushButton *nameButton; QPushButton *sexButton; QPushButton *ageButton; QPushButton *statureButton; QLabel *label1; QLabel *label2; QLabel *label3; QLabel *label4; QLabel *nameLabel; QLabel *sexLabel; QLabel *ageLabel; QLabel *statureLabel; private slots: void slotName(); void slotAge(); void slotSex(); void slotStature(); }; #endif // INPUT_H 实现代码 main.cpp #include <QApplication> #include <QDialog> #include <QTextCodec> #include <QLabel> #include <QFrame> #include <QPushButton> #include <QGridLayout> #include <QInputDialog> #include <QStringList> #include "input.h" InputDlg::InputDlg(){ //设置窗口标题 setWindowTitle(