我需要将一个矩形绕其中心点旋转,并在QWidget的中心显示它。你能完成这个特定代码吗?如果可能的话,能否简化解释或提供最简单的解释链接?
请注意:我已经阅读了Qt文档,编译了处理旋转的示例/演示文稿,但我仍然无法理解它!
void Canvas::paintEvent(QPaintEvent *event)
{
QPainter paint(this);
paint.setBrush(Qt::transparent);
paint.setPen(Qt::black);
paint.drawLine(this->width()/2, 0, this->width()/2, this->height());
paint.drawLine(0, this->height()/2, this->width(), this->height()/2);
paint.setBrush(Qt::white);
paint.setPen(Qt::blue);
// Draw a 13x17 rectangle rotated to 45 degrees around its center-point
// in the center of the canvas.
paint.drawRect(QRect(0,0, 13, 17));
}