【发布时间】:2020-12-04 07:41:59
【问题描述】:
我有这样的代码:
#include <QApplication>
#include <QGraphicsPolygonItem>
#include <QGraphicsScene>
#include <QGraphicsView>
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
QGraphicsScene scene;
QGraphicsView view;
view.resize(640, 400);
view.setScene(&scene);
auto polygon = new QGraphicsPolygonItem;
auto brush = QBrush(QColor(255, 0, 0));
polygon->setBrush(brush);
auto pen = QPen(brush, 20);
pen.setCapStyle(Qt::RoundCap);
polygon->setPen(pen);
QPolygonF polygonPath;
polygonPath << QPointF{-50, -50};
polygonPath << QPointF{100, -50};
polygonPath << QPointF{100, 100};
polygonPath << QPointF{-50, 100};
polygon->setPolygon(polygonPath);
scene.addItem(polygon);
view.show();
return app.exec();
}
尽管我设置了圆帽,但多边形项目会以直帽呈现。
我在这里做错了什么吗?
【问题讨论】:
标签: c++ qt qt5 qgraphicsscene qgraphicsitem