Finding invisible items in QGraphicsView?
I'm porting a game using QGraphicsView (or trying to at least!) and need items to fade in as they scroll into the view.
There seem to be some fancy optimizations in the framework that make almost fully transparent items effectively invisible. Unfortunately invisible items are not found by any of the items() overloads so it's hard to know which items to increase the opacity on. I say "almost" fully transparent because there appears to be no difference between setting some arbitrary low value and zero. Is the minimum opacity documented anywhere or is it paint engine specific?
Is there another way to find items that would be on the view if they weren't invisible?
I can make this work and look OK on the N8 by using a minimum opacity of 0.01 for "invisible" items but I'd like to know if there's a less hacky way of producing the effect.
Well, try to delete unused items from scene, or you can subclass QGraphicsItem and add hidden flag to it. If is hidden, then do not add it to scene, for instance.
Thanks but the items aren't unused, they're just invisible and should gradually fade in and then out again as they scroll through the view.
Essentially I put all the items for a side-scrolling 2D game into the scene and let the graphics view architecture be my game engine. If I don't add the items to the scene then I have to work out when they'll scroll into the view myself, which completely loses the point of using graphics view. Unfortunately if they're invisible (or just almost completely transparent), the graphics view doesn't appear to have a way to tell me they're there either. :(
It works OK with opacitiy 0.01 because you can't actually see that (at least in motion) anyway but it just seemed like a bit of a hack.