PDA

View Full Version : drawing errors



Dp0H
27th February 2012, 09:52
Hello.
Qt 4.8.0
QGraphicsView scale factor 3.779527559..
The following code

painter->setPen(Qt::red);
painter->drawRect(0, 0, 10, 10);

painter->setPen(Qt::darkGreen);
painter->drawLine(0, 3, 10, 3);

painter->setPen(Qt::blue);
painter->drawLine(3, 2, 3, 7);
painter->drawLine(3, 5, 8, 5);
gives (contrast lines in front of other drawings - just for test)
7439

It is possible to adjust the view's scale factor to avoid off-lying resections, but it's unacceptable.
May I avoid these strange sticks?

wysota
27th February 2012, 10:01
Do you have antialiasing enabled when drawing those lines?

Dp0H
27th February 2012, 10:16
Antialiasing disabled. With some other sizes the green line does not cover the red square by it's right end, and i could imagine some kind of explanation for this.
But I can't explain _this_ situation.
With Qt 4.7.x there were some problems on the opposite side (+-1 pixel precision), but it was difficult to notice.

wysota
27th February 2012, 11:02
Could you prepare a minimal compilable example reproducing the problem?

Dp0H
27th February 2012, 11:50
It's interesting.. Simple example draws ok. I'll try to prepare the (bad :) ) working example for you. Thanks

wysota
27th February 2012, 12:04
It's interesting.. Simple example draws ok.
That's what usually happens :D

Dp0H
28th February 2012, 06:13
I've prepared the project:
7448
Press the buttons to animate :)
That is awful..

wysota
28th February 2012, 07:16
I don't have time to test everything right now but from skeeming your code I can say your setRect() implementation is somewhat incorrect (it shouldn't influence the primary problem though).

setPos() should be expressed in the coordinate space of the parent item, so putting it in the same call as setting bounding rect for the item might be confusing for the user.

As for the main problem I'm guessing it all have to do with inability to express every fractional number in the datatype used. Increase your scaling and all should be fine.

Dp0H
28th February 2012, 07:51
It's report designer. Current scale factor leads to 1:1 paper to screen representation. How can I just increase my scaling?
It looks like Qt::FlatCap resolves the problem. I suggest this behaviour is incorrect for cosmetic pen.