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

新余市网站建设_网站建设公司_字体设计_seo优化

信息类网站,望野王绩拼音版,高明网站建设,wordpress 4.6在上篇 《C设计模式——Bridge模式#xff08;上#xff09;》中我们对于桥接模式做了一些介绍。介于桥接模式在实际项目开发中使用广泛#xff0c;而且也是面试中常问常新的话题。在本篇#xff0c;我们专注bridge模式在具体的项目开发中的应用#xff0c;举几个例子来说…在上篇 《C设计模式——Bridge模式上》中我们对于桥接模式做了一些介绍。介于桥接模式在实际项目开发中使用广泛而且也是面试中常问常新的话题。在本篇我们专注bridge模式在具体的项目开发中的应用举几个例子来说明。 #ifndef SHAPE_H #define SHAPE_H#include QObject #include QWidget #include QColor #include QPointF #include QPaintEvent #include QPainter #include QPen #include QBrush #include QDebugclass ShapeImp;class Shape {public:virtual void draw() 0;virtual void setLineColor(const QColor color) 0;virtual void setLineWidth(const int width) 0;virtual ~Shape() {} protected:Shape(ShapeImp* imp) : imp_(imp) {}ShapeImp* imp_; };class ShapeImp : public QWidget { public:virtual void draw() 0;virtual void setLineColor(const QColor color) 0;virtual void setLineWidth(const int width) 0;virtual ~ShapeImp() {} protected:ShapeImp(QWidget* parent nullptr):QWidget(parent) {}friend class Shape; };class ShapeImpWin : public Shape { public:ShapeImpWin(ShapeImp* pImpl) : Shape(pImpl) {} public: // operationvoid draw() override{ imp_-draw(); }void setLineColor (const QColor color) override { imp_-setLineColor(color); }void setLineWidth(const int width) override { imp_-setLineWidth(width);} };class Circle : public ShapeImp {Q_OBJECT public:Circle(const QPointF center,qreal raduis,QWidget* parent nullptr): m_center(center),m_raduis(raduis),ShapeImp(parent){}void draw(){ update(); }void setLineColor(const QColor color) override {m_color color;}void setLineWidth(const int width) override{ m_lineWidth width; }virtual void paintEvent(QPaintEvent* e) override{QPainter painter(this);QPen pen;pen.setColor( m_color /*QColor(Qt::red)*/);pen.setWidth(m_lineWidth);QBrush brush;brush.setColor(QColor(Qt::lightGray));painter.setPen(pen);painter.setBrush(brush);// draw circlepainter.drawEllipse(m_center,m_raduis,m_raduis);e-accept();}private:QPointF m_center;qreal m_raduis 50;QColor m_color QColor(Qt::black);int m_lineWidth 1; };class Rectange : public ShapeImp {Q_OBJECT public:Rectange(const QPointF topleft,qreal width,qreal height,QWidget* parent nullptr): m_topleft(topleft),m_width(width),m_height(height),ShapeImp(parent){}void draw(){ update(); }void setLineColor(const QColor color) override {m_color color;}void setLineWidth(const int width) override{ m_lineWidth width; }virtual void paintEvent(QPaintEvent* e) override{QPainter painter(this);QPen pen;pen.setColor( m_color /*QColor(Qt::red)*/);pen.setWidth(m_lineWidth);QBrush brush;brush.setColor(QColor(Qt::lightGray));painter.setPen(pen);painter.setBrush(brush);// draw circleQRectF r(m_topleft.x(),m_topleft.y(),m_width,m_height);painter.drawRect(r);qDebug() r;e-accept();}private:QPointF m_topleft;qreal m_width 100;qreal m_height 100;QColor m_color QColor(Qt::black);int m_lineWidth 1; }; #endif // SHAPE_H#include board.h#include QApplication #include shape.h #include QHBoxLayoutint main(int argc, char *argv[]) {QApplication a(argc, argv);ShapeImp* pImpl_circle new Circle(QPointF(100,100),80);pImpl_circle-setFixedSize(300,300);Shape* pShape new ShapeImpWin(pImpl_circle);pShape-setLineWidth(1);pShape-setLineColor(QColor(Qt::red));pShape-draw();pImpl_circle-show();ShapeImp* pImpl_rect new Rectange(QPointF(10,10),80,80);pImpl_rect-setFixedSize(300,300);Shape* pShap1 new ShapeImpWin(pImpl_rect);pShap1-setLineWidth(1);pShap1-setLineColor(QColor(Qt::red));pShap1-draw();pImpl_rect-show();return a.exec(); }
http://www.ihoyoo.com/news/40422.html

相关文章:

  • 网站开发需要什么配置的电脑建立网站的内容规划
  • 网站标题写什么作用常州做网站的企业
  • 岳阳二手房网站物联网应用技术学什么就业方向
  • 淄博网站制作品牌定制seo免费培训视频
  • 怎么把网站推广出去微网站建设服务商
  • 兰州网站建设加王道下拉商标设计要求及规范
  • 网站建立的研究方案wordpress后台总是404
  • 小企业网站建设怎样公众号菜单栏页面模板
  • 目前做的最好的招聘网站公益网站 做公益赚钱
  • 中国住房城乡建设部网站首页七台河做网站
  • 网站建设免费模板郑州二七区最新消息
  • 制作asp手机网站58同城关键词怎么优化
  • 最专业微网站首选公司网站续费模板
  • 奥远网站建设流程网站优化的方式有哪些
  • 大型网站的空间南京网站建设有限公司
  • 用python做网站前端有谁做过网站建设
  • 建设网站比较好的公司排名网络推广专家
  • 加强思政部网站建设做亚马逊一个月挣10万
  • 建设网站话术网页制作框架教程
  • 用家用路由器ip做网站wordpress菜单 链接
  • 网站换了域名做跳转做网站能给公司带来什么好处
  • 廊坊专业网站网站网站建设工资高吗
  • 雅虎网站收录提交入口网站建设四不问题
  • 需要上传视频的网站龙岩天宫山简介概况
  • 高校网站一般采用什么网页布局工信部域名查询
  • 自己做的网站如何联网网站全部用根目录
  • 贺州招聘网站建设版面设计绘画
  • 莆田市建设局网站做外贸哪个网站最好
  • 网站首页大小招聘网站开发兼职
  • 青岛网站建设公司哪家好优化水平