【发布时间】:2015-08-01 10:49:11
【问题描述】:
我正在使用 PyQt 和更准确的 QPainter 来绘制一条线。我需要围绕原点(如时钟手柄)旋转这条线,但我认为设置它是不可能的!
我找到了setTransformOriginPoint,但它不适用于QPainter 对象。无法为QTransform 和rotate 设置原点,这可能会影响QPainter 对象。
我也尝试手动旋转线,使用旋转方程和...,这是代码:
def rotateLine(x, y, d):
d = math.radians(d)
x2 = x * math.cos(d) - y * math.sin(d)
y2 = x * math.sin(d) + y * math.cos(d)
return x2, y2
des = QPoint(400, 0)
for k in range(0, 10):
paint.drawLine(center, des)
newLine = rotateLine(des.x(), des.y(), 45)
des = QPoint(newLine[0], newLine[1])
logging.warning(des)
但它不能正常工作! 我该怎么办?
【问题讨论】:
标签: qt rotation pyqt transform qpainter