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

上海企业网站制作报价关键词分析软件

上海企业网站制作报价,关键词分析软件,新型网站建设,微网站怎么做微名片重新实现paintEvent()函数。 效果如下&#xff1a; 效果为蓝色区域&#xff0c;背景是vs接面&#xff0c;代码直接复制可用&#xff0c;留给有需要的人。 #ifndef CircleWidget_h__ #define CircleWidget_h__#include <QWidget>class CCircleWidget : public QWidget {Q…

重新实现paintEvent()函数。

效果如下:

 效果为蓝色区域,背景是vs接面,代码直接复制可用,留给有需要的人。

#ifndef CircleWidget_h__
#define CircleWidget_h__#include <QWidget>class CCircleWidget : public QWidget
{Q_OBJECTpublic:explicit CCircleWidget(QWidget* parent = 0); // explicit 避免歧义CCircleWidget(const QString& strImagePath, int nRadius, QWidget* parent = 0);public:void SetNormalOutLineColor(QColor color);void SetHoverOutLineColor(QColor color);void SetPressedOutLineColor(QColor color);void SetOutLineWidth(int nWidth);void SetImagePath(const QString& strImagePath);void SetHovered(bool bHovered);void SetPressed(bool bPressed);protected: // overridevoid Init();void paintEvent(QPaintEvent*) override;                // 绘图事件,调用update()时触发void mousePressEvent(QMouseEvent* e) override;          // 鼠标按下事件void mouseReleaseEvent(QMouseEvent* e) override;        // 鼠标释放事件void enterEvent(QEvent*) override;                     // 鼠标进入事件void leaveEvent(QEvent*) override;                     // 鼠标离开事件signals:void SigClicked(); // 点击信号private:QString m_strImagePath; // 图片路径QColor m_normalColor;QColor m_hoverColor;QColor m_pressedColor;int m_nWidth;int m_nRadius;        // 圆形半径bool m_bPressed;      // 左键单击控制bool m_bHovered;      // 鼠标悬停控制
};#endif // CircleWidget_h__
#include "CircleWidget.h"
#include <QPainter>
#include <QMouseEvent>CCircleWidget::CCircleWidget(QWidget* parent): QWidget(parent), m_strImagePath(":/dotnetIcon.png"), m_normalColor("#58a3ef"), m_hoverColor("#6eb8f5"), m_pressedColor("#417cac"), m_nWidth(4), m_nRadius(46), m_bPressed(false), m_bHovered(false)
{Init();
}CCircleWidget::CCircleWidget(const QString& strImagePath, int nRadius, QWidget* parent): QWidget(parent), m_strImagePath(strImagePath), m_normalColor("#58a3ef"), m_hoverColor("#6eb8f5"), m_pressedColor("#417cac"), m_nWidth(4), m_nRadius(nRadius), m_bPressed(false), m_bHovered(false)
{Init();
}void CCircleWidget::SetNormalOutLineColor(QColor color)
{m_normalColor = color;
}void CCircleWidget::SetHoverOutLineColor(QColor color)
{m_hoverColor = color;
}void CCircleWidget::SetPressedOutLineColor(QColor color)
{m_pressedColor = color;
}void CCircleWidget::SetOutLineWidth(int nWidth)
{m_nWidth = nWidth;
}void CCircleWidget::SetImagePath(const QString& strImagePath)
{m_strImagePath = strImagePath;
}void CCircleWidget::SetHovered(bool bHovered)
{m_bHovered = bHovered;update();
}void CCircleWidget::SetPressed(bool bPressed)
{m_bPressed = bPressed;update();
}void CCircleWidget::Init()
{// 无边框setWindowFlags(Qt::FramelessWindowHint);// 窗口背景透明setAttribute(Qt::WA_TranslucentBackground, true);
}void CCircleWidget::paintEvent(QPaintEvent*)
{QPainter p(this);p.setRenderHint(QPainter::Antialiasing);QPen pen;pen.setWidth(m_nWidth);if (m_bPressed){pen.setColor("#417cac"); // 按下时的边框颜色}else if (m_bHovered){pen.setColor("#6eb8f5"); // 悬停时的边框颜色}else{pen.setColor("#58a3ef"); // 正常状态的边框颜色}p.setPen(pen);p.setBrush(Qt::NoBrush);// 设置圆心为圆的半径,以确保圆形完整显示//QPoint center(m_nRadius + m_nWidth / 2, m_nRadius + m_nWidth / 2);QPoint center(rect().center());// 绘制背景圆形p.drawEllipse(center, m_nRadius, m_nRadius);// 绘制图片QPixmap pixmap(m_strImagePath);QRect imageRect(0, 0, 2 * m_nRadius, 2 * m_nRadius); // 计算图片绘制区域QPainterPath clipPath;clipPath.addEllipse(center, m_nRadius, m_nRadius);p.setClipPath(clipPath);p.drawPixmap(center.x() - m_nRadius, center.y() - m_nRadius, imageRect.width(), imageRect.height(), pixmap);
}void CCircleWidget::mousePressEvent(QMouseEvent* e)
{m_bPressed = true;update();
}void CCircleWidget::mouseReleaseEvent(QMouseEvent* e)
{m_bPressed = false;update();
}void CCircleWidget::enterEvent(QEvent*)
{m_bHovered = true;update();
}void CCircleWidget::leaveEvent(QEvent*)
{m_bHovered = false;update();
}
http://www.yayakq.cn/news/933163/

相关文章:

  • 福建微网站建设价格wordpress设置邮件注册
  • 营销型网站建设设计服务wordpress图片广告代码
  • 陕西网站建设哪家强沈阳网站建设服务器
  • 网站信用建设应该用什么技术网站模板 单页
  • 临夏金属装饰网站建设0791网站建设
  • 郑州网站推广效果怎么把本地wordpress上传
  • 机械做网站百度电话查询
  • 网站静态网架公司是做什么的
  • 珠海网站外包台州营销型网站建设
  • 全球著名科技网站wordpress怎么添加论坛
  • 网站做零售网站推广的常用途径有哪些
  • 电子商务网站建设的核心多选手机网站的开发
  • 商城网站建设方案 2017扬州市市政建设处网站
  • 个人网站开发计划书某景区网站建设策划书
  • 口碑好的网站建设公司哪家好市场推广计划怎么写
  • 站内优化做视频网站的公司有哪些
  • 广州网站建设工作室招聘满洲里网站建设
  • 深圳宝安高端网站建设报价网站开发摊销期多少年
  • wordpress 做api接口百度seo外链推广教程
  • 英语写作网站建网页网站
  • 住房和城乡建设部网站造价王者荣耀网页设计报告
  • 架设网站多少钱一个服务器可以做两个网站吗
  • 外贸商城网站建设网站降权如何恢复
  • 优化网站页面网页广告调词平台多少钱
  • 三更app下载网站阳朔网站建设公司
  • 网站建设套餐有哪些如何设计好的网页
  • 网站建设所需硬件南京制作网站速成班
  • 网站在哪里备案ps淘宝网页设计教程
  • 网站开发人员 生活怎么在公众号做影视网站
  • 营销型网站建设的优势有哪些网站开发建设需要多少钱