2
我想绘制一个角度的矩形。它可以工作,但是当我改变角度时,矩形的位置正在改变。我无法理解它。有人给我一只手吗?QPainterPath QTransform :: map
这里是我的代码:
QPoint point = QPoint(100,100); // has to be shown at this point
QSize size = QSize(30,30);
QRect rect = QRect(point,size);
QPainterPath Path ;
Path.addRect(rect);
QTransform t;
t.rotate(myAngle);
QPainterPath newPath= t.map(Path);
QwtPlotShapeItem *Item = new QwtPlotShapeItem("Shape Name");
Item->setItemAttribute(QwtPlotItem::Legend, true);
Item->setRenderHint(QwtPlotItem::RenderAntialiased, true);
Item->setShape(newPath);
Item->setPen(Qt::black);
Item->setBrush(QColor("Grey"));
Item->attach(this);
我认为map()函数导致此问题。但我不知道为什么。感谢您的建议