Line Becomes Large Square
-
When I draw a line with length 1, i.e. the start point and end point are the same, and then I zoom, the line suddenly becomes a large square of size 10x10. When the line has a length of 2+ then it stays just 1 pixel wide. Why is this happening and how to I prevent it?
As background info, I am trying to use this to draw individual pixels.
-
What kind of drawing are you talking about? QPainter, QPainterPath, QGraphicsItem, OpenGL?
-
-
Hi.
I think that there are some bug if the same starting point and end point.
But you should do something like this:QPen pen(Qt::red); pen.setWidth(2); // If it stay just 1 pixel wide, set 1 pen.setCosmetic(true); yourScene->addLine(0, 0, 0, 0, pen);
@Devopia53 setting cosmetic to true does keeps the line with length 1 as 1 pixel. However, it doesn't zoom anymore. That's of course the purpose of cosmetic but I still need it to zoom. So if I zoom in 16x then my line of length 1 should be 16 screen pixels wide. But at the moment when I turn off cosmetic the lines with length 1 become like 80 pixels wide. That happens as soon as I zoom in/out (before it has the correct size).