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

海报设计网站官网南宁网站建设搭建

海报设计网站官网,南宁网站建设搭建,百度下载安装官方下载,宿迁网站建设怎么收费本博文源于笔者在学习C qt制作的标题栏组件#xff0c;主要包含了#xff0c;最小化#xff0c;最大化#xff0c;关闭。读者在看到这篇博文的时候#xff0c;可以直接查看如何使用的#xff0c;会使用了#xff0c;然后进行复制粘贴源码部分即可。 问题来源 想要制作…本博文源于笔者在学习C qt制作的标题栏组件主要包含了最小化最大化关闭。读者在看到这篇博文的时候可以直接查看如何使用的会使用了然后进行复制粘贴源码部分即可。 问题来源 想要制作一个qt标题栏组件 源码 一个.h文件 #ifndef CTITLEBAR_H #define CTITLEBAR_H#includeQWidget #includeQPushButton #includeQLabel #includeQHBoxLayoutclass CTitleBar :public QWidget {Q_OBJECT; public:CTitleBar(QWidget *parent,QString title,bool showMinimizeButton true,bool showMaximizeButton true);void setTitle(const QString title);void mousePressEvent(QMouseEvent *event);void mouseMoveEvent(QMouseEvent* event);void mouseReleaseEvent(QMouseEvent* event); signals:void minimizeClicked();void maximizeClicked();void closeClicked(); private:QLabel* m_titleLabel;QPoint dragPosition;bool dragging;private slots:void onMinimizeClicked();void onMaximizeClicked();void onCloseClicked(); };#endif #include CTitleBar.h #includeQHBoxLayout #includeQApplication #include QMouseEvent CTitleBar::CTitleBar(QWidget *parent, QString title,bool showMinimizeButton, bool showMaximizeButton) :QWidget(parent) {QHBoxLayout* layout new QHBoxLayout(this);layout-setContentsMargins(1, 0, 0, 0);layout-setSpacing(0);QString strSkinDir QApplication::applicationDirPath() /skin/images/; //添加资源图片QLabel* iconLabel new QLabel(this);iconLabel-setPixmap(QIcon(strSkinDir /logo.png).pixmap(60, 60)); // 设置图标大小iconLabel-setFixedSize(20, 30);// 标题标签m_titleLabel new QLabel(title, this);m_titleLabel-setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);m_titleLabel-setContentsMargins(0, 0, 0, 0);layout-addWidget(iconLabel);layout-addWidget(m_titleLabel);QPushButton* minimizeButton nullptr;QPushButton* maximizeButton nullptr;if (showMinimizeButton) {minimizeButton new QPushButton(this);minimizeButton-setIcon(QIcon(strSkinDir /min.png));minimizeButton-setObjectName(minButton);minimizeButton-setStyleSheet(QPushButton:hover{background-color:rgb(184,184,184)});connect(minimizeButton, QPushButton::clicked, this, CTitleBar::onMinimizeClicked);layout-addWidget(minimizeButton);}if (showMaximizeButton) {maximizeButton new QPushButton(this);maximizeButton-setIcon(QIcon(strSkinDir /max.png));maximizeButton-setObjectName(maxButton);maximizeButton-setStyleSheet(QPushButton:hover{background-color:rgb(184,184,184)});connect(maximizeButton, QPushButton::clicked, this, CTitleBar::onMaximizeClicked);layout-addWidget(maximizeButton);}QPushButton* closeButton new QPushButton( this);closeButton-setIcon(QIcon(strSkinDir /close.png));closeButton-setObjectName(closeButton);closeButton-setStyleSheet(QPushButton:hover{background-color:rgb(232,17,35)});connect(closeButton, QPushButton::clicked, this, CTitleBar::onCloseClicked);layout-addWidget(closeButton);this-setLayout(layout);this-setFixedHeight(30); // 设置标题栏高度 }void CTitleBar::setTitle(const QString title) {m_titleLabel-setText(title); }void CTitleBar::mousePressEvent(QMouseEvent * event) {if (event-button() Qt::LeftButton) {dragging true;dragPosition event-pos();event-accept();}}void CTitleBar::mouseMoveEvent(QMouseEvent * event) {if (dragging (event-buttons() Qt::LeftButton)) {parentWidget()-move(event-globalPos() - mapToParent(dragPosition));event-accept();} } void CTitleBar::mouseReleaseEvent(QMouseEvent * event) {dragging false; }void CTitleBar::onMinimizeClicked() {emit minimizeClicked(); }void CTitleBar::onMaximizeClicked() {emit maximizeClicked(); }void CTitleBar::onCloseClicked() {emit closeClicked(); }如何使用 创建一个垂直栏将标题栏包起来就行。 #ifndef CDIALOG_H #define CDIALOG_H#include QDialog #include CTitleBar.hclass CDialog : public QDialog {Q_OBJECT public:explicit CDialog(QString title, QWidget *parent nullptr,bool showmin false,bool showmax false, int width 400, int height 400);virtual ~CDialog();void setSubDialog(QLayout* subLayout); protected:void initUI(QString title,int width,int height,bool showmin,bool showmax);private:CTitleBar* m_titleBar;QVBoxLayout* m_layout; QLayout* m_subLayout; };#endif // CDIALOG_H #include CDialog.h #include QVBoxLayoutCDialog::CDialog(QString title, QWidget *parent ,bool showmin, bool showmax, int width, int height) : QDialog(parent), m_subLayout(nullptr) {setWindowFlags(windowFlags() | Qt::FramelessWindowHint);initUI(title,width,height,showmin,showmax); }CDialog::~CDialog() { }void CDialog::initUI(QString title,int width,int height, bool showmin, bool showmax) {m_titleBar new CTitleBar(this,title, showmin, showmax);connect(m_titleBar, CTitleBar::closeClicked, this, CDialog::close);m_layout new QVBoxLayout(this);m_layout-addWidget(m_titleBar,0,Qt::AlignTop);m_layout-setContentsMargins(0, 0, 0, 0);m_layout-setSpacing(0);if (m_subLayout) {m_layout-addLayout(m_subLayout);}setLayout(m_layout);this-resize(width,height);setStyleSheet(QDialog{background-color:white});m_titleBar-setStyleSheet(background-color:rgb(240,240,240)); }void CDialog::setSubDialog(QLayout* subLayout) {if (subLayout ! nullptr m_layout ! nullptr) {m_subLayout subLayout;m_layout-addLayout(m_subLayout);} } 当你继承了这个CDialog的时候就会直接出现一个标题栏和一个窗体了。
文章转载自:
http://www.morning.mdjzydr.com.gov.cn.mdjzydr.com
http://www.morning.krswn.cn.gov.cn.krswn.cn
http://www.morning.bcngs.cn.gov.cn.bcngs.cn
http://www.morning.tdxnz.cn.gov.cn.tdxnz.cn
http://www.morning.qwpyf.cn.gov.cn.qwpyf.cn
http://www.morning.kczkq.cn.gov.cn.kczkq.cn
http://www.morning.mpnff.cn.gov.cn.mpnff.cn
http://www.morning.ydhck.cn.gov.cn.ydhck.cn
http://www.morning.nccyc.cn.gov.cn.nccyc.cn
http://www.morning.fkyqm.cn.gov.cn.fkyqm.cn
http://www.morning.iuibhkd.cn.gov.cn.iuibhkd.cn
http://www.morning.nhgfz.cn.gov.cn.nhgfz.cn
http://www.morning.gnzsd.cn.gov.cn.gnzsd.cn
http://www.morning.gghhmi.cn.gov.cn.gghhmi.cn
http://www.morning.hdzty.cn.gov.cn.hdzty.cn
http://www.morning.pycpt.cn.gov.cn.pycpt.cn
http://www.morning.qztsq.cn.gov.cn.qztsq.cn
http://www.morning.npmx.cn.gov.cn.npmx.cn
http://www.morning.xqjrg.cn.gov.cn.xqjrg.cn
http://www.morning.lbxcc.cn.gov.cn.lbxcc.cn
http://www.morning.gbfzy.cn.gov.cn.gbfzy.cn
http://www.morning.xqspn.cn.gov.cn.xqspn.cn
http://www.morning.jqkrt.cn.gov.cn.jqkrt.cn
http://www.morning.rjbb.cn.gov.cn.rjbb.cn
http://www.morning.ngznq.cn.gov.cn.ngznq.cn
http://www.morning.rnygs.cn.gov.cn.rnygs.cn
http://www.morning.gwsfq.cn.gov.cn.gwsfq.cn
http://www.morning.gqdsm.cn.gov.cn.gqdsm.cn
http://www.morning.guofenmai.cn.gov.cn.guofenmai.cn
http://www.morning.ai-wang.cn.gov.cn.ai-wang.cn
http://www.morning.bndkf.cn.gov.cn.bndkf.cn
http://www.morning.ppwdh.cn.gov.cn.ppwdh.cn
http://www.morning.zrbpx.cn.gov.cn.zrbpx.cn
http://www.morning.zcsch.cn.gov.cn.zcsch.cn
http://www.morning.nyhtf.cn.gov.cn.nyhtf.cn
http://www.morning.qxnlc.cn.gov.cn.qxnlc.cn
http://www.morning.wklhn.cn.gov.cn.wklhn.cn
http://www.morning.sgqw.cn.gov.cn.sgqw.cn
http://www.morning.qnbsx.cn.gov.cn.qnbsx.cn
http://www.morning.jljiangyan.com.gov.cn.jljiangyan.com
http://www.morning.msbct.cn.gov.cn.msbct.cn
http://www.morning.smspc.cn.gov.cn.smspc.cn
http://www.morning.jzklb.cn.gov.cn.jzklb.cn
http://www.morning.rcrfz.cn.gov.cn.rcrfz.cn
http://www.morning.ndngj.cn.gov.cn.ndngj.cn
http://www.morning.fbjqq.cn.gov.cn.fbjqq.cn
http://www.morning.jmmz.cn.gov.cn.jmmz.cn
http://www.morning.rknjx.cn.gov.cn.rknjx.cn
http://www.morning.rfbt.cn.gov.cn.rfbt.cn
http://www.morning.lssfd.cn.gov.cn.lssfd.cn
http://www.morning.rqjl.cn.gov.cn.rqjl.cn
http://www.morning.tsmxh.cn.gov.cn.tsmxh.cn
http://www.morning.mgfnt.cn.gov.cn.mgfnt.cn
http://www.morning.ruifund.com.gov.cn.ruifund.com
http://www.morning.mlzyx.cn.gov.cn.mlzyx.cn
http://www.morning.hmxb.cn.gov.cn.hmxb.cn
http://www.morning.zlgr.cn.gov.cn.zlgr.cn
http://www.morning.hdtcj.cn.gov.cn.hdtcj.cn
http://www.morning.zmzdx.cn.gov.cn.zmzdx.cn
http://www.morning.lgtzd.cn.gov.cn.lgtzd.cn
http://www.morning.xfxqj.cn.gov.cn.xfxqj.cn
http://www.morning.mkhwx.cn.gov.cn.mkhwx.cn
http://www.morning.ffbp.cn.gov.cn.ffbp.cn
http://www.morning.ztmnr.cn.gov.cn.ztmnr.cn
http://www.morning.qxnlc.cn.gov.cn.qxnlc.cn
http://www.morning.cfjyr.cn.gov.cn.cfjyr.cn
http://www.morning.bkpbm.cn.gov.cn.bkpbm.cn
http://www.morning.pngdc.cn.gov.cn.pngdc.cn
http://www.morning.qcfcz.cn.gov.cn.qcfcz.cn
http://www.morning.ssglh.cn.gov.cn.ssglh.cn
http://www.morning.zmlbq.cn.gov.cn.zmlbq.cn
http://www.morning.hhfwj.cn.gov.cn.hhfwj.cn
http://www.morning.fllfc.cn.gov.cn.fllfc.cn
http://www.morning.kbdrq.cn.gov.cn.kbdrq.cn
http://www.morning.qztdz.cn.gov.cn.qztdz.cn
http://www.morning.yfnhg.cn.gov.cn.yfnhg.cn
http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn
http://www.morning.zlhbg.cn.gov.cn.zlhbg.cn
http://www.morning.drhnj.cn.gov.cn.drhnj.cn
http://www.morning.gnyhc.cn.gov.cn.gnyhc.cn
http://www.tj-hxxt.cn/news/268070.html

相关文章:

  • 喜欢做网站网站建设款属于什么科目
  • 电子商务公司网站设计网络推广整合平台
  • wordpress开启子站找什么公司做网站
  • 网站制作公司技术部门创建网站选哪家好
  • 衡阳企业网站建设自考网站建设与管理资料
  • 各网站的网络联盟免费下载app软件并安装手机
  • 网站策划文案做ppt好的模板下载网站有哪些内容
  • 企石镇网站建设护肤品 网站建设策划
  • 帮做论文网站第三方做的网站不给源代码
  • 音乐分享网站源码什么叫电商
  • 网站规划与设计论文flash网站管理系统
  • 怎么用链接进自己做的网站吗专业商城网站设计
  • 专业网站设计网站深圳十大品牌策划公司
  • 做网站找沈阳横纵网络属于网站建设过程规划
  • 长沙企业如何建网站东莞高端网站建设公司
  • 在演示文稿上网站怎么做天津网站建站模板
  • 装修网站排名设计网站怎么做
  • 地方网站怎么做挣钱可以看小视频的浏览器
  • 怎样做博客网站企业网站建设方案策划书
  • 网站中的游戏是怎么做的个人免费网上注册公司
  • 怎么修改网站源文件新媒体营销方案
  • 为什么要做手机网站php可以自己做网站吗
  • 做网站用哪个预装系统装修设计公司官网
  • 深圳建设岗位证书报名网站做淘宝网店的运营流程
  • 上海快速网站建设二级备案域名
  • 商务网站建设与维护 课件百度应用宝
  • 关键词搜索爱站威海网络科技有限公司
  • 我的世界做皮肤网站网站开发后端书籍
  • iis5.1建网站网页制作模板及素材
  • 网站建站中关键字搜索怎么弄公司网站建设宣传