Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 Qt 中绘制一个椭圆,并且边缘的边框在某些地方变得很薄。
这是代码:
QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen(Qt::black, 3)); painter.drawEllipse(event->rect());
有任何想法吗?提前致谢。
绘制带有轮廓的形状时,您必须考虑笔的宽度。因此,在您的情况下,更改为:
// Adjusted by 2 pixels because half your pen width is 1.5, but QRect is // for integer types, so rounded up. painter.drawEllipse(event->rect().adjusted( -2, -2, 2, 2 ) );