[Qt-interest] Bug in Qt 4.5.1 QGraphicsItem setOpacity?

Ian Thomson Ian.Thomson at iongeo.com
Thu Apr 30 09:21:30 CEST 2009


I didn't take a deep look at the floating point stuff first time round. 
It actually seems fine now that I take another look.

I guess it appears that Qt does not redraw the graphics item when its 
opacity changes to close to 0.0. You should report this to the Qt bug 
tracker.

Cheers,
Ian.

Murphy, Sean M. wrote:
> Thanks for checking!  I played with it some more, and in my
> fadeTimeout() function, where I check whether the opacity is <= 0.0, if
> at that point, you put in a line of code to stop the timer, then when
> run the application, you'll get the following behavior.  The items fade
> in to full intensity (1.0), then fade out to where they are still
> slightly visible and then the timer stops (which only happens at <=
> 0.0).  If at that point,  you click OUT of this application, causing
> some other application window to get window focus, then a repaint
> happens which does make the 4 colored items go completely transparent.
> I haven't figured out the right Qt repaint call to explicitly make this
> happen in my own code though.
> 
> What's your theory on the floating point stuff?  I understand the
> dangers of comparing floats in general, but in this example, I'm
> starting at 0.0, adding 0.2 several times, and then subtracting 0.2
> several times.  Even though 0.2 can't be correctly represented in
> floating point numbers, whatever that value is, should be deterministic,
> correct?  And since my limits check whether I'm >= 1.0 or <=0.0, the
> worst that could happen is 0.0 + 5 * 0.2 is something slightly less than
> 1.0, and the loop would run one more time to something slightly less
> than 1.2 before it flips?  Or am I missing something else?
> 
> Sean
> 
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Ian Thomson
> Sent: Wednesday, April 29, 2009 10:55 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Bug in Qt 4.5.1 QGraphicsItem setOpacity?
> 
> Hi,
> 
> I can confirm I see the same thing on red hat 5 linux with Qt 4.5.1.
> 
> I examined your test program and I am suspicious that there could be a 
> problem with floating point comparisons, but in any case just setting 
> the opacity to 0.0 doesn't seem to alter how it is displayed. It does 
> seem to be a Qt issue.
> 
> Hope this helps,
> Ian.
> 
> Murphy, Sean M. wrote:
>> I've got problem with setting the opacity on QGraphicsPixmapItem's.  I
>> first noticed it in my real application, and then came up with a test
>> application that reproduces the problem, which I've included.
>>
>> When you run the test application, you get a QGraphicsScene with a
>> checkerboard pattern background.  Over the top of the background, I've
>> put in 4 colored QGraphicsPixmapItem's.  I then have a timer that sets
>> the opacity of the 4 colored items from 0.0 to 1.0 in 0.2 steps, then
>> decreases the opacity from 1.0 to 0.0 in 0.2 steps, and repeats this
>> process forever.
>>
>> On my Mac running Qt 4.5.0 this seems to work perfectly, when the
>> opacity of the tiles is 1.0 I can't see the checkerboard pattern
> through
>> them, and when their opacity is set to 0.0, I can only see the
>> checkerboard pattern.
>>
>> On my Windows machine, running the versions of Qt and mingw provided
> by
>> qt-sdk-win-commercial-2009.02.exe, at opacity of 1.0 the checkerboard
>> pattern is hidden (correct), but when the opacity is 0.0, I can still
>> see evidence of the tile colors superimposed over the checkerboard
>> pattern.
>>
>> Can anyone confirm this?
>>
>> Does anyone know what to do to work around it?  On Windows, explicitly
>> hiding the items when their opacity reaches 0.0 doesn't seem to work
>> either...
>>
>> Sean
>>
>>
>>
> ------------------------------------------------------------------------
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list