Advertisement
VictoriaLodochkina

lab 7 z1 2 sem

Apr 21st, 2020
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.80 KB | None | 0 0
  1. #include "widget.h"
  2. #include "ui_widget.h"
  3.  
  4. Widget::Widget(QWidget *parent)
  5.     : QWidget(parent)
  6.     , ui(new Ui::Widget)
  7. {
  8.     ui->setupUi(this);
  9. }
  10.  
  11. Widget::~Widget()
  12. {
  13.     delete ui;
  14. }
  15. void Widget::paintEvent(QPaintEvent *event){
  16.     QPainter paint(this);
  17.     QStyleOption opt;
  18.     opt.init(this);
  19.     style()->drawPrimitive(QStyle::PE_Widget, &opt, &paint, this);
  20.     paint.setRenderHint(QPainter::Antialiasing, true);
  21.     paint.setBrush(QBrush(Qt::red));
  22.     paint.setPen(QPen(Qt::black, 2));
  23.     paint.drawPie(QRect(310, 120, 180, 340), -180*16, -90*16);//красный
  24.     paint.setBrush(QBrush(Qt::magenta));
  25.     paint.drawPie(QRect(310, 120, 180, 340), -270*16, -90*16);//фиолетовый
  26.     paint.setBrush(QBrush(Qt::blue));
  27.     paint.drawPie(QRect(350, 120, 120, 340), -180*16, -90*16);//синий
  28.     paint.setBrush(QBrush(Qt::green));
  29.     paint.drawPie(QRect(350, 120, 120, 340), -270*16, -90*16);//зеленый
  30.     paint.setBrush(QBrush(Qt::yellow));
  31.     paint.drawPie(QRect(390, 120, 40, 340), -180*16, -180*16);//желтый
  32.     paint.setBrush(Qt::white);
  33.     for (int i=310; i<470; i+=40){
  34.     paint.drawPie(QRect(i, 272, 40, 40), -180*16, -180*16);}
  35.     paint.drawPie(QRect(470, 272, 40, 40), -180*16, -90*16);
  36.     paint.setPen(QPen(Qt::white, 2));
  37.     paint.drawLine(310, 292, 490, 292);
  38.     paint.drawLine(490, 292, 490, 274);
  39.     paint.setPen(QPen(Qt::black, 4));
  40.     paint.drawLine(400, 277, 400, 390);//ручка
  41.     paint.drawArc(400, 365, 50, 50, 180*16, 180*16);//ручка
  42.     paint.setBrush(QBrush(Qt::black));
  43.     paint.setPen(QPen(Qt::black, 4));
  44.     QPolygon polygon;
  45.     polygon << QPoint(396, 119) << QPoint(400, 109) << QPoint(404, 119);
  46.     paint.drawPolygon(polygon);
  47.     paint.setPen(QPen(Qt::black, 2));
  48.     paint.drawLine(400, 109, 400, 103);
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement