Qt精彩实例(4)& 自己实现的软件管家界面

实例12.qq用户资料修改
layoutdlg.h
#ifndef LAYOUTDLG_H
#define LAYOUTDLG_H
 
 
#include <QtGui> 
class layoutdlg:public QDialog 
{
 //Q_OBJECT 
public:
 layoutdlg(QWidget *parent=0, Qt::WindowFlags f=0);
 QLabel *label1;
 QLabel *label2;
 QLabel *label3;
 QLabel *label4;
 QLabel *label5;
 QLabel *label6;
 QLabel *label7;
 QLabel *labelOther;
 QLabel *labelIcon;
 QLineEdit *lineEditUser;
 QLineEdit *lineEditName;
 QComboBox *comboBoxSex;
 QTextEdit *textEditDepartment;
 QSpinBox *lineEditAge;
 QTextEdit *textEditDisc;
 QPushButton *pushButtonIcon;
 QPushButton *pushButtonOK;
 QPushButton *pushButtonExit;
};
 
 
#endif // LAYOUTDLG_H 
layoutdlg.cpp 
 
 
#include "layoutdlg.h" 
layoutdlg::layoutdlg(QWidget *parent,Qt::WindowFlags f)
 :QDialog(parent,f)
{
 setWindowTitle(tr("User Information"));
 
 
 label1 = new QLabel(tr("User Name"));
 label2 = new QLabel(tr("Name"));
 label3 = new QLabel(tr("Sex"));
 label4 = new QLabel(tr("Department"));
 label5 = new QLabel(tr("Age:"));
 labelOther = new QLabel(tr("Remark"));
 labelOther->setFrameStyle(QFrame::Panel|QFrame::Sunken);
 lineEditUser = new QLineEdit;
 lineEditName = new QLineEdit;
 comboBoxSex = new QComboBox;
 comboBoxSex->insertItem(0,tr("Female"));
 comboBoxSex->insertItem(1,tr("Male"));
 textEditDepartment = new QTextEdit();
 lineEditAge = new QSpinBox;
 lineEditAge->setMinimum(0);
 lineEditAge->setMaximum(200);
 
 
 QGridLayout *leftLayout = new QGridLayout();
 
 
 int labelCol = 0;
 int contentCol = 1;
 leftLayout->addWidget(label1,0,labelCol);
 leftLayout->addWidget(lineEditUser,0,contentCol);
 leftLayout->addWidget(label2,1,labelCol);
 leftLayout->addWidget(lineEditName,1,contentCol);
 leftLayout->addWidget(label3,2,labelCol);
 leftLayout->addWidget(comboBoxSex,2,contentCol);
 leftLayout->addWidget(label4,3,labelCol,Qt::AlignTop);
 leftLayout->addWidget(textEditDepartment,3,contentCol);
 leftLayout->addWidget(label5,4,labelCol);
 leftLayout->addWidget(lineEditAge,4,contentCol);
 leftLayout->addWidget(labelOther,5,labelCol,1,2);
 leftLayout->setColumnStretch(0,1);
 leftLayout->setColumnStretch(1,3);
 
 
 label7 = new QLabel(tr("Head"));
 labelIcon = new QLabel();
 QPixmap icon("E:/Qt/w/images/1.png");
 labelIcon->resize(icon.width(),icon.height());
 labelIcon->setPixmap(icon);
 pushButtonIcon = new QPushButton();
 pushButtonIcon->setText(tr("Change"));
 QHBoxLayout *hLayout = new QHBoxLayout;
 hLayout->setSpacing(20);
 hLayout->addWidget(label7);
 hLayout->addWidget(labelIcon);
 hLayout->addWidget(pushButtonIcon);
 
 
 label6 = new QLabel(tr("Individual:"));
 textEditDisc = new QTextEdit();
 QVBoxLayout *rightLayout = new QVBoxLayout();
 rightLayout->setMargin(10);
 rightLayout->addLayout(hLayout);
 rightLayout->addWidget(label6);
 rightLayout->addWidget(textEditDisc);
 
 
 pushButtonOK = new QPushButton(tr("OK"));
 pushButtonExit = new QPushButton(tr("Cancel"));
 QHBoxLayout *bottomLayout = new QHBoxLayout();
 bottomLayout->addStretch();
 bottomLayout->addWidget(pushButtonOK);
 bottomLayout->addWidget(pushButtonExit);
 
 
 QGridLayout *mainLayout = new QGridLayout(this);
 mainLayout->setMargin(15);
 mainLayout->setSpacing(10);
 mainLayout->addLayout(leftLayout,0,0);
 mainLayout->addLayout(rightLayout,0,1);
 mainLayout->addLayout(bottomLayout,1,0,1,2);
 mainLayout->setSizeConstraint(QLayout::SetFixedSize);
 
 
 connect(pushButtonExit, SIGNAL(clicked()), this, SLOT(close()));
}
main.cpp 
 
 
 
 
#include <QApplication> // 所有QT图形化应用程序必须包含此文件,它包含了QT图形化应用程序的各种资源、基本设置、控制流及事件处理等。 
#include "layoutdlg.h" // 自定义类头文件 
 
 
 
 
int main(int argc, char *argv[])
{
 QApplication app(argc, argv);
 layoutdlg *pDlg = new layoutdlg();
 pDlg->show();
 return app.exec();
}
 
Qt精彩实例(4)& <wbr>自己实现的软件管家界面
 
 
 
自己实现的类似一般杀毒软件的界面: 
代码放在github上:https://github.com/XiaoqingGao/QtGUI  
界面截图如下:
 
Qt精彩实例(4)& <wbr>自己实现的软件管家界面
 
 
 
 
Qt精彩实例(4)& <wbr>自己实现的软件管家界面
 
转自 http://blog.sina.com.cn/s/blog_6a1e0bf30100zqq3.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值