我使用 aQPainter
用以下代码绘制我的小部件:
QPen pen(Qt::black, 0.6, Qt::SolidLine);
QPainter painter(this);
painter.setPen(pen);
// vertical
painter.drawLine(startX,0,startX,50);
painter.drawLine((startX += grid),0,startX,50);
painter.drawLine((startX += grid),0,startX,50);
painter.drawLine((startX += grid),0,startX,50);
painter.drawLine((startX += grid),0,startX,50);
painter.drawLine((startX += grid),0,startX,50);
// horizontal
pen.setWidth(0.7);
painter.setPen(pen);
painter.drawLine(0,grid*2,70,grid*2);
painter.drawLine(0,grid*4,70,grid*4);
painter.drawLine(0,grid*6,70,grid*6);
painter.drawLine(0,grid*8,70,grid*8);
当我将此项目添加到 aQGraphicsScene
时,线条的宽度有时看起来彼此不同,尤其是当我放大时。谁能解释为什么会发生这种情况以及可以做些什么来解决它?
此屏幕截图演示了该问题: