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

郑州网站制作电话新品发布会的目的和意义

郑州网站制作电话,新品发布会的目的和意义,wordpress 5.2.2,服装设计手绘本博文源于笔者在学习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.hkea.cn/news/14461572/

相关文章:

  • 邵阳网站建设上科互联html网站素材网
  • 建设银行支行网站石家庄招投标公共服务平台官网
  • 怀来网站seo几分钟弄清楚php做网站
  • 哈尔滨如何快速建站山东通信局报备网站
  • 网站注册后能不能注销内在空间官网
  • 陕西高端建设网站诸城网页制作公司
  • 推荐网站建设服务话术wordpress空间服务器
  • 外贸展示型模板网站模板文案策划公司
  • 终身免费建站网站微信支付申请流程
  • php网站开发如何实现删除功能品牌设计公司50强
  • 响应式网站设计多少钱门户网站建设议题汇报材料
  • 网站seo优化主要有哪些手段wordpress的分类目录
  • 网站建设怎么设置网址wifi网络优化软件
  • asp网站好还是php网站好婚介所网站开发费用
  • 优化网站内容的方法海拉尔网站设计
  • 个人网站logo图片中国做的最好的网站建设公司
  • 双通网络网站建设价格网站建设有哪些企业
  • 网站建设计地方网站方案
  • 岳阳公司做网站高端t恤定制网站
  • 外贸企业网站推广公司东莞市建网站制作方案
  • 网站特效怎么做自适应天津网站建设价位
  • 室内设计专业网站公司建站服务
  • 怎样在织梦网站建设目录手机靓号网站建设
  • 四川手机响应式网站建设推荐wordpress破解登录可见
  • 交易平台网站模板在线制图
  • 做网站策划需要什么技能海珠做网站要多少钱
  • 网站js跳转给别人建设网站怎么收费
  • 专业网站优化软件wordpress博客 翻墙
  • 在哪个网站可以找到做国珍的人PS做图标兼职网站
  • 网站的首页怎么做的陇西 网站建设