资源描述:
《duplicate18linux窗口程序设计-qt4精彩实例分析实例4使用标准输入框》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、//inputdialog.h#ifndefINPUTDLG_H#defineINPUTDLG_H#includeclassInputDlg:publicQDialog{Q_OBJECTpublic:InputDlg();public:QPushButton*nameButton;QPushButton*sexButton;QPushButton*ageButton;QPushButton*statureButton;QLabel*label1;QLabel*label2;QLabel*label3;QLab
2、el*label4;QLabel*nameLabel;QLabel*sexLabel;QLabel*ageLabel;QLabel*statureLabel;privateslots:voidslotName();voidslotSex();voidslotAge();voidslotStature();};#endif//inputdialog.cpp#include"inputdialog.h"InputDlg::InputDlg(){setWindowTitle(tr("InputDialog"));label1=n
3、ewQLabel(tr("Name:"));label2=newQLabel(tr("Sex:"));label3=newQLabel(tr("Age:"));label4=newQLabel(tr("Stature:"));nameLabel=newQLabel(tr("LiMing"));nameLabel->setFrameStyle(QFrame::Panel
4、QFrame::Sunken);sexLabel=newQLabel(tr("male"));sexLabel->setFrameStyle(QFrame:
5、:Panel
6、QFrame::Sunken);ageLabel=newQLabel(tr("25"));ageLabel->setFrameStyle(QFrame::Panel
7、QFrame::Sunken);statureLabel=newQLabel("175.5");statureLabel->setFrameStyle(QFrame::Panel
8、QFrame::Sunken);nameButton=newQPushButton;nameButton->setIcon(QIcon(":/images/btn.pn
9、g"));sexButton=newQPushButton;sexButton->setIcon(QIcon(":/images/btn.png"));ageButton=newQPushButton;ageButton->setIcon(QIcon(":/images/btn.png"));statureButton=newQPushButton;statureButton->setIcon(QIcon(":/images/btn.png"));QGridLayout*layout=newQGridLayout(this
10、);intname=0;intsex=1;intage=2;intstature=3;layout->addWidget(label1,name,0);layout->addWidget(nameLabel,name,1);layout->addWidget(nameButton,name,2);layout->addWidget(label2,sex,0);layout->addWidget(sexLabel,sex,1);layout->addWidget(sexButton,sex,2);layout->addWid
11、get(label3,age,0);layout->addWidget(ageLabel,age,1);layout->addWidget(ageButton,age,2);layout->addWidget(label4,stature,0);layout->addWidget(statureLabel,stature,1);layout->addWidget(statureButton,stature,2);layout->setMargin(15);layout->setSpacing(10);layout->set
12、ColumnMinimumWidth(1,120);connect(nameButton,SIGNAL(clicked()),this,SLOT(slotName()));connect(sexButton,SIGNAL(clicked()),this,SLOT(slotSex()));connect(