Qt-interest Archive, January 2007
ugly QGraphicsEllipseItem when small
Message 1 in thread
I have trouble drawing 'dots' with the QGraphicsSceneEllipse.
The thing is : when I use myEllipse->setRect( x , y , size , size );
and size is small (4,5,6,8 for instance), I get an ugly shape, like this :
This is for size = 5
* * * * *
* *
* *
* *
* *
* * *
Then pen is not set, so it must be default (SolidLine)
Is there something I can do about that ?
--
[ signature omitted ]
Message 2 in thread
On 1/21/07, eb <eb5@xxxxxxxxxx> wrote:
>
> I have trouble drawing 'dots' with the QGraphicsSceneEllipse.
>
> The thing is : when I use myEllipse->setRect( x , y , size , size );
> and size is small (4,5,6,8 for instance), I get an ugly shape, like this :
>
Try turning on the anti-aliasing painting hint in the QGraphicsView. That
should help.
best,
Jeroen
Message 3 in thread
Jeroen Wijnhout wrote:
> On 1/21/07, eb <eb5@xxxxxxxxxx> wrote:
>>
>> I have trouble drawing 'dots' with the QGraphicsSceneEllipse.
>>
>> The thing is : when I use myEllipse->setRect( x , y , size , size );
>> and size is small (4,5,6,8 for instance), I get an ugly shape, like this
>> :
>>
>
> Try turning on the anti-aliasing painting hint in the QGraphicsView. That
> should help.
>
> best,
> Jeroen
Thanks for this hint, it works, BUT : it totally ruins the other items.
I had neat lines, which become blurred. Yuck.
:-(
--
[ signature omitted ]
Message 4 in thread
eb wrote:
> Thanks for this hint, it works, BUT : it totally ruins the other items.
> I had neat lines, which become blurred. Yuck.
> :-(
You can either adjust the pen width of those items, or only enable
antialiasing for your ellipse items, by subclassing QGraphicsEllipseItem
and reimplementing paint().
Andreas
--
[ signature omitted ]
Message 5 in thread
eb schrieb:
> Jeroen Wijnhout wrote:
>> ...
>> Try turning on the anti-aliasing painting hint in the QGraphicsView. That
>> should help.
>>
>> best,
>> Jeroen
>
> Thanks for this hint, it works, BUT : it totally ruins the other items.
> I had neat lines, which become blurred. Yuck.
Then just use anti-aliasing where you need it, e.g. your ellipses. Draw
the other objects without anti-aliasing, e.g. your lines.
Cheers, Oliver
--
[ signature omitted ]
Message 6 in thread
Till Oliver Knoll wrote:
> eb schrieb:
>> Jeroen Wijnhout wrote:
>>> ...
>>> Try turning on the anti-aliasing painting hint in the QGraphicsView.
>>> That should help.
>>>
>>> best,
>>> Jeroen
>>
>> Thanks for this hint, it works, BUT : it totally ruins the other items.
>> I had neat lines, which become blurred. Yuck.
>
> Then just use anti-aliasing where you need it, e.g. your ellipses. Draw
> the other objects without anti-aliasing, e.g. your lines.
>
> Cheers, Oliver
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
How would I do that simply ?
I had the understanding that antialias render hint was a the graphic view
level ?
Andreas proposes to reimplement paint(), but that seems to me an overkill.
(not mentioning the fact that I would be incapable of ...)
--
[ signature omitted ]
Message 7 in thread
eb schrieb:
> Till Oliver Knoll wrote:
>
>> eb schrieb:
>>> Jeroen Wijnhout wrote:
>>>> ...
>>>> Try turning on the anti-aliasing painting hint in the QGraphicsView.
>>>> That should help.
>>>>
>>>> best,
>>>> Jeroen
>>> Thanks for this hint, it works, BUT : it totally ruins the other items.
>>> I had neat lines, which become blurred. Yuck.
>> Then just use anti-aliasing where you need it, e.g. your ellipses. Draw
>> the other objects without anti-aliasing, e.g. your lines.
>>
>> Cheers, Oliver
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body. List archive and information:
>> http://lists.trolltech.com/qt-interest/
>
> How would I do that simply ?
> I had the understanding that antialias render hint was a the graphic view
> level ?
If you're using a QPainter:
void QPainter::setRenderHint ( RenderHint hint, bool on = true )
it's as simple as that. QPainter is a _state machine_, in other words
you can enable/disable anti-aliasing whenever needed.
If on the other hand the painting itself is not under control by you
(but by the entire QGraphicsView) then I don't know - from the
QGraphicsView documentation it indeed looks like the render hint is
global to all objects (I have never used QGraphicsView myself, so I
might be wrong):
"renderHints : QPainter::RenderHints
These hints are used to initialize QPainter before each visible item is
drawn. QPainter uses render hints to toggle rendering features such as
antialiasing and smooth pixmap transformation."
So if you want to turn on anti-aliasing for _certain_ objects only, turn
it off globally, subclass those objects in question and turn on
anti-aliasing in the overridden paint() method, as someone else already
suggested (after painting is done disable it again). Yes, it's a bit
overkill, maybe there's a simpler way to do it, but I don't know.
Cheers, Oliver
--
[ signature omitted ]
Message 8 in thread
Till Oliver Knoll wrote:
>
> If you're using a QPainter:
>
> void QPainter::setRenderHint ( RenderHint hint, bool on = true )
>
> it's as simple as that. QPainter is a _state machine_, in other words
> you can enable/disable anti-aliasing whenever needed.
>
> If on the other hand the painting itself is not under control by you
> (but by the entire QGraphicsView) then I don't know - from the
> QGraphicsView documentation it indeed looks like the render hint is
> global to all objects (I have never used QGraphicsView myself, so I
> might be wrong):
>
> "renderHints : QPainter::RenderHints
>
> These hints are used to initialize QPainter before each visible item is
> drawn. QPainter uses render hints to toggle rendering features such as
> antialiasing and smooth pixmap transformation."
>
> So if you want to turn on anti-aliasing for _certain_ objects only, turn
> it off globally, subclass those objects in question and turn on
> anti-aliasing in the overridden paint() method, as someone else already
> suggested (after painting is done disable it again). Yes, it's a bit
> overkill, maybe there's a simpler way to do it, but I don't know.
>
> Cheers, Oliver
>
>
Thx for all this. I'll give it a try.
--
[ signature omitted ]