我正在尝试在圆柱体上绘制文本。这意味着我有五行文本。顶部一行沿X轴旋转10度。第二行为5度。中间一行不旋转。第四行旋转-5度。第五行旋转-10度。
前三行的绘制正常,但第四、五行出现了问题。我做错了什么?
我提供了一张图片以便理解问题和代码片段:
for( int i = 0; i < iterationsCount; ++i )
{
const QRect r( x2, y2, textWidth, itemHeight );
const QString text = sections.at( section ).values.at( index );
int rsc = 0;
p->save();
rsc = widgetHeight / 2 - y;
p->setTransform(QTransform().rotate(rsc, Qt::XAxis));
if( type == Section::DaySectionShort ||
type == Section::DaySectionLong )
{
QStringList values = text.split( QLatin1Char( ' ' ) );
p->setPen(
lighterColor( opt.palette.color( QPalette::WindowText ), 75 ) );
p->drawText( r, Qt::AlignLeft | Qt::TextSingleLine, values.at( 0 ) );
p->setPen( opt.palette.color( QPalette::WindowText ) );
p->drawText( r, Qt::AlignLeft | Qt::TextSingleLine, values.at( 1 ) );
}
else
{
p->drawText( r, Qt::AlignLeft | Qt::TextSingleLine, text );
}
p->setTransform(QTransform().rotate(-rsc, Qt::XAxis));
index = nextIndex( index, sections.at( section ).values.size() );
y += itemHeight + itemTopMargin;
p->restore();
}
QTransform().rotate(-rsc...)
而不使用p
?而且为什么rsc
的计算如此奇怪? - ilotXXInextIndex
函数中完成的吗? - ilotXXI