I use a QPainter
to draw my widget with this code:
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);
When I add this item into a QGraphicsScene
, the width of the lines sometimes look different from each other, especially when I zoom in. Can anyone explain why this is happening and what can be done to fix it?
This screen shot demonstrates the problem: