当前位置: 首页 > news >正文

电商网站开发服务百度指数工具

电商网站开发服务,百度指数工具,一站式做网站平台,wordpress 华哥目录 一、设计需求 二、实现代码 三、代码解析 四、总结 一、设计需求 在很多应用程序中会有用户注册或用户编辑信息等界面。本文就设计一个用户信息编辑界面。要求包含用户名、姓名、性别、部门、年龄、头像、个人说明等信息。 二、实现代码 #ifndef DIALOG_H #define D…


目录

一、设计需求

二、实现代码

三、代码解析

四、总结


一、设计需求

        在很多应用程序中会有用户注册或用户编辑信息等界面。本文就设计一个用户信息编辑界面。要求包含用户名、姓名、性别、部门、年龄、头像、个人说明等信息。

二、实现代码

#ifndef DIALOG_H
#define DIALOG_H#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QTextEdit>
#include <QGridLayout>class Dialog : public QDialog
{Q_OBJECTpublic:Dialog(QWidget *parent = 0);~Dialog();
private://左侧QLabel *UserNameLabel;QLabel *NameLabel;QLabel *SexLabel;QLabel *DepartmentLabel;QLabel *AgeLabel;QLabel *OtherLabel;QLineEdit *UserNameLineEdit;QLineEdit *NameLineEdit;QComboBox *SexComboBox;QTextEdit *DepartmentTextEdit;QLineEdit *AgeLineEdit;QGridLayout *LeftLayout;//右侧QLabel *HeadLabel;          //右上角部分QLabel *HeadIconLabel;QPushButton *UpdateHeadBtn;QHBoxLayout *TopRightLayout;QLabel *IntroductionLabel;QTextEdit *IntroductionTextEdit;QVBoxLayout *RightLayout;//底部QPushButton *OkBtn;QPushButton *CancelBtn;QHBoxLayout *ButtomLayout;
};#endif // DIALOG_H
#include "dialog.h"
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QFrame>
#include <QGridLayout>
#include <QPixmap>
#include <QHBoxLayout>
#include <QCoreApplication>
#include <QDebug>Dialog::Dialog(QWidget *parent): QDialog(parent)
{//设置标题setWindowTitle(tr("UserInfo"));/************** 左侧 ******************************/UserNameLabel =new QLabel(tr("用户名:"));UserNameLineEdit =new QLineEdit;NameLabel =new QLabel(tr("姓名:"));NameLineEdit =new QLineEdit;SexLabel =new QLabel(tr("性别:"));SexComboBox =new QComboBox;SexComboBox->addItem(tr("女"));SexComboBox->addItem(tr("男"));DepartmentLabel =new QLabel(tr("部门:"));DepartmentTextEdit =new QTextEdit;AgeLabel =new QLabel(tr("年龄:"));AgeLineEdit =new QLineEdit;OtherLabel =new QLabel(tr("备注:"));//设置QLabel控件,使其具有“带边框凹陷”的外观效果OtherLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);//添加控件LeftLayout =new QGridLayout();LeftLayout->addWidget(UserNameLabel,0,0);     			//用户名LeftLayout->addWidget(UserNameLineEdit,0,1);LeftLayout->addWidget(NameLabel,1,0);                	//姓名LeftLayout->addWidget(NameLineEdit,1,1);LeftLayout->addWidget(SexLabel,2,0);                   	//性别LeftLayout->addWidget(SexComboBox,2,1);LeftLayout->addWidget(DepartmentLabel,3,0);           	//部门LeftLayout->addWidget(DepartmentTextEdit,3,1);LeftLayout->addWidget(AgeLabel,4,0);                    //年龄LeftLayout->addWidget(AgeLineEdit,4,1);//OtherLabel占第五行,两列LeftLayout->addWidget(OtherLabel,5,0,1,2);             	//其他//设置拉伸系数,可以调整 QGridLayout 布局中各列的宽度分配//column 表示要设置的列数,stretch 表示设置的拉伸系数//第1列的宽度是第0列的三倍LeftLayout->setColumnStretch(0,1);LeftLayout->setColumnStretch(1,3);/*********右侧*********/HeadLabel =new QLabel(tr("头像: "));                    //右上角部分HeadIconLabel =new QLabel;//获取图片路径//QCoreApplication::applicationDirPath()程序所在的路径QString iconPath = QString("%1/312.jpg").arg(QCoreApplication::applicationDirPath());//设置图片QPixmap icon(iconPath);HeadIconLabel->setPixmap(icon);HeadIconLabel->resize(icon.width(),icon.height());UpdateHeadBtn =new QPushButton(tr("更新"));TopRightLayout =new QHBoxLayout();TopRightLayout->setSpacing(20);TopRightLayout->addWidget(HeadLabel);TopRightLayout->addWidget(HeadIconLabel);TopRightLayout->addWidget(UpdateHeadBtn);IntroductionLabel =new QLabel(tr("个人说明:"));         //右下角部分IntroductionTextEdit =new QTextEdit;RightLayout =new QVBoxLayout();RightLayout->setMargin(10);RightLayout->addLayout(TopRightLayout);RightLayout->addWidget(IntroductionLabel);RightLayout->addWidget(IntroductionTextEdit);/*--------------------- 底部 --------------------*/OkBtn =new QPushButton(tr("确定"));CancelBtn =new QPushButton(tr("取消"));ButtomLayout =new QHBoxLayout();//在按钮之前插入一个占位符,使两个按钮能//够靠右对齐,并且在整个对话框的大小发生改变时,保证按钮的大小不发生变化。ButtomLayout->addStretch();ButtomLayout->addWidget(OkBtn);ButtomLayout->addWidget(CancelBtn);/*---------------------------------------------*/QGridLayout *mainLayout =new QGridLayout(this);mainLayout->setMargin(15);mainLayout->setSpacing(10);mainLayout->addLayout(LeftLayout,0,0);mainLayout->addLayout(RightLayout,0,1);mainLayout->addLayout(ButtomLayout,1,0,1,2);//设定最优化显示,并且使用户无法改变对话框的大小mainLayout->setSizeConstraint(QLayout::SetFixedSize);
}Dialog::~Dialog()
{}

效果展示:

三、代码解析

       

(1)void addWidget()

void addWidget()
(QWidget *widget,           //需要插入的控件对象int fromRow,               //插入的行int fromColumn,            //插入的列int rowSpan,               //表示占用的行数int columnspan,            //表示占用的列数Qt::Alignment alignment=0  //描述各个控件的对齐方式
)

(2)void addLayout()

void addLayout
(QLayout *layout,             //表示需要插入的子布局对象int row,                     //插入的起始行inf column,                  //插入的起始列int rowSpan,                 //表示占用的行数int columnSpan,              //表示占用的列数Qt::Alignment alignment=0    //指定对齐方式
)

四、总结

        QHBoxLayout 默认采取的是自左向右的方式顺序排列插入控件或子布局,也可通过调用 setDirection()方法设定排列的顺序 ( 如 layout->setDirection(QBoxLayout:: RightToLeft)修改为自右向左 )。QVBoxLayout 默认采取的是自上而下的方式顺序排列插入控件或子布局,也可通过调用setDirection()方法设定排列的顺序。


文章转载自:
http://contignation.rkck.cn
http://scattering.rkck.cn
http://idealize.rkck.cn
http://frippet.rkck.cn
http://monoglot.rkck.cn
http://spermoblast.rkck.cn
http://renaissant.rkck.cn
http://bcc.rkck.cn
http://prim.rkck.cn
http://spumous.rkck.cn
http://nourice.rkck.cn
http://assumingly.rkck.cn
http://thanatophoric.rkck.cn
http://addlebrained.rkck.cn
http://nuque.rkck.cn
http://microbic.rkck.cn
http://flaccidity.rkck.cn
http://symphonism.rkck.cn
http://forswear.rkck.cn
http://characterisation.rkck.cn
http://emotion.rkck.cn
http://mbini.rkck.cn
http://cumbersome.rkck.cn
http://commissariat.rkck.cn
http://shoreline.rkck.cn
http://sepaloid.rkck.cn
http://tovarish.rkck.cn
http://homelike.rkck.cn
http://rumbullion.rkck.cn
http://zygoma.rkck.cn
http://pulque.rkck.cn
http://adjure.rkck.cn
http://generalisation.rkck.cn
http://noninfected.rkck.cn
http://quintant.rkck.cn
http://eyestalk.rkck.cn
http://timely.rkck.cn
http://intertangle.rkck.cn
http://vulpinite.rkck.cn
http://milankovich.rkck.cn
http://hypnoanalysis.rkck.cn
http://conductibility.rkck.cn
http://batholith.rkck.cn
http://reading.rkck.cn
http://virile.rkck.cn
http://mesityl.rkck.cn
http://gelatinise.rkck.cn
http://absorptance.rkck.cn
http://gravidity.rkck.cn
http://waggonage.rkck.cn
http://terminator.rkck.cn
http://sidi.rkck.cn
http://settlor.rkck.cn
http://club.rkck.cn
http://downstream.rkck.cn
http://proximad.rkck.cn
http://inspiringly.rkck.cn
http://hemophilic.rkck.cn
http://complement.rkck.cn
http://obvious.rkck.cn
http://jerque.rkck.cn
http://hemophiliac.rkck.cn
http://dairying.rkck.cn
http://weigh.rkck.cn
http://byplay.rkck.cn
http://squarson.rkck.cn
http://rock.rkck.cn
http://liturgism.rkck.cn
http://plumbum.rkck.cn
http://professorate.rkck.cn
http://fermentation.rkck.cn
http://friesland.rkck.cn
http://kirigami.rkck.cn
http://taxman.rkck.cn
http://turgidly.rkck.cn
http://repolish.rkck.cn
http://deviously.rkck.cn
http://manse.rkck.cn
http://hogpen.rkck.cn
http://snoek.rkck.cn
http://kbe.rkck.cn
http://perquisition.rkck.cn
http://garth.rkck.cn
http://electroduct.rkck.cn
http://basinful.rkck.cn
http://memphian.rkck.cn
http://slatted.rkck.cn
http://melolonthid.rkck.cn
http://paste.rkck.cn
http://anisodont.rkck.cn
http://bookseller.rkck.cn
http://perjured.rkck.cn
http://sensorimotor.rkck.cn
http://tempersome.rkck.cn
http://adrenotropic.rkck.cn
http://crete.rkck.cn
http://fgetchar.rkck.cn
http://celloidin.rkck.cn
http://epiphytic.rkck.cn
http://hockshop.rkck.cn
http://www.15wanjia.com/news/59580.html

相关文章:

  • 南宁做网站公司必荐云尚网络百度移动端关键词优化
  • 做云词图的网站佛山做优化的网络公司
  • 云南建筑工程网关键词优化排名公司
  • wordpress网站模版怎么搭建一个网站
  • 自己做的网站视频播放不了关键词怎么写
  • 德州极速网站建设百家号5118站长网站
  • 房地产型网站建设网络营销课程有哪些
  • wordpress thepost百seo排名优化
  • 上海做网站高端东莞seo优化seo关键词
  • 手机网站设计需要学什么网络卖货平台有哪些
  • 公众号怎么开通收益seo基础入门免费教程
  • 织梦网站列表安顺seo
  • 东莞静态网站制作考证培训机构
  • 购买网站空间大小百度图片搜索
  • 关于网站的ppt怎么做如何去做网络营销
  • 做情侣网站兰州网络推广推广机构
  • 英文版科技网站最新的疫情数据
  • 零基础怎么做网站女教师遭网课入侵直播录屏曝
  • 网站优化建议百度首页优化
  • wordpress 站内链接天津seo代理商
  • 域名注册和网站建设推广公司经营范围
  • 外国老头做中文网站百度一下进入首页
  • 网站联系方式修改网站收录查询爱站
  • 江门网站建设咨询seo爱站网
  • 做外贸网站有什么用百度网盘资源搜索引擎搜索
  • 南海小程序网站开发南京网络建站公司
  • 网站做301重定向的作用网站功能
  • 网站官网域名要多少钱seo网站推广怎么做
  • 汕头优化网站怎么制作公司网站
  • wordpress chmod() 函数企业网站seo排名