#include "mainwindow.h" #include "ui_mainwindow.h" #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); GraphicsColorPathItem *pathItem1 = new GraphicsColorPathItem(); GraphicsColorPathItem *pathItem2 = new GraphicsColorPathItem(); GraphicsColorPathItem *pathItem3 = new GraphicsColorPathItem(); QPolygonF poly1; QPolygonF poly2; poly1.append(QPointF(72.80599977946001, -20.0)); poly1.append(QPointF(79.4595245353603, -20.0)); poly1.append(QPointF(175.0, -20.0)); poly1.append(QPointF(175.0, 20.0)); poly1.append(QPointF(85.83632192403258, 20.0)); poly1.append(QPointF(72.80599977946001, -20.0)); poly2.append(QPointF(138.90690452319478, -20.0)); poly2.append(QPointF(132.25337970676924, -19.999999999999996)); poly2.append(QPointF(-175.0, -19.999999999999996)); poly2.append(QPointF(-175.0, 20.0)); poly2.append(QPointF(0.0, 20.0)); poly2.append(QPointF(125.87658237835221, 20.0)); poly2.append(QPointF(138.90690452319478, -20.0)); QPolygonF poly3 = poly1.intersected(poly2); pathItem1->setPolygon(poly1); pathItem2->setPolygon(poly2); pathItem1->setBorderColor(QColor(Qt::GlobalColor::blue)); pathItem1->setBorderSize(2); pathItem1->setZValue(2); pathItem2->setBorderColor(QColor(Qt::GlobalColor::red)); pathItem2->setBorderSize(3); pathItem2->setZValue(1); pathItem3->setPolygon(poly3); pathItem3->setBorderColor(QColor(Qt::GlobalColor::yellow)); pathItem3->setBorderSize(1); pathItem3->setZValue(3); QGraphicsScene *scene = new QGraphicsScene(); scene->addItem(pathItem1); scene->addItem(pathItem2); scene->addItem(pathItem3); ui->graphicsView->setScene(scene); ui->graphicsView->setTransform(QTransform(5, 0, 0, 5, 0, 0)); } MainWindow::~MainWindow() { delete ui; }