其实这断代码没什么优秀之处,贴出来主要为为了方便自己和他人,因为以后如果用到这一块的话,这些代码可能能够直接拿过来用。

InpugDialog.h头文件:

#ifndef INPUGDIALOG_H #define INPUGDIALOG_H #include <QtGui> #include "ui_inpugdialog.h" class InpugDialog : public QDialog { Q_OBJECT public: InpugDialog(QWidget *parent = 0, Qt::WFlags flags = 0); ~InpugDialog(); 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: Ui::InpugDialogClass ui; private slots: void slotName(); void slotSex(); void slotAge(); void slotStature(); }; #endif // INPUGDIALOG_H

InpugDialog.cpp文件

main.cpp

下面粘贴一下效果图:

QT中的QInputDialog的小例子

QT中的QInputDialog的小例子

QT中的QInputDialog的小例子

QT中的QInputDialog的小例子

QT中的QInputDialog的小例子

相关文章: