文本的绘制,通常需要按照一定的角度绘制,我们可以通过QT的坐标转换来实现:
void
drawRotatedText(
QPainter
*painter,
float
degrees,
int
x,
int
y,
const
QString
&text)
{
painter->save(); //保存原来坐标系统
painter->translate(x, y); //平移坐标原点到 x, y
painter->rotate(degrees); //坐标旋转degrees 度
painter->drawText(0, 0, text); //在原点绘制文本
painter->restore(); //回复原来的坐标系统
}