Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Finding invisible items in QGraphicsView?
Qt 6.11 is out! See what's new in the release blog

Finding invisible items in QGraphicsView?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m_p_wilcox
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarkoSiroki
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        m_p_wilcox
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved