QGraphicsView, can't stop system caching pixmaps

  • I have a QT app that has a 2-D map interface that draws icons over the map. A new feature request is that the icons alone can be viewed without the map background.

    The maps are broken into tiles on the filesystem, and are loaded/unloaded from memory in a separate thread (as QImages). The GUI process itself has an update that takes these QImages when they've been read from disc, then loads them as QGraphicsPixmapItems (within the GUI process).

    This is a small demo app, nothing commercial. There are three different map layers, topographics maps, FAA charts, and OpenStreetMaps. Switching between all of these works fine, and has for a long time.

    I have a simple button in my GUI to turn off the map layer under the icons, but no matter how I try to get this working, I can't make the map images go away completely.

    The QGraphicsPixmapItems that are the map tiles are grouped together into a QGraphicsItemGroup. I've tried setting visibility of this group to false, I've tried individually setting the pixmap items to not be visible, removing the pixmaps from the graphicsview, removing the pixmap group from the graphicsview, unloading the pixmaps from memory, all with the same results

    When any of these methods are attempted the map stops updating itself, as in I can drag the map interface around, and the map tiles no long move with the geo referenced icons (mouse drag), however it seems the map tiles are still being drawn from some kind of cache. I also get odd rendering issues for the icons/elements that are still "active" (see pics in link)

    "Imgur link to two pics, normal and with the map supposedly disabled, while dragging the display around":http://imgur.com/a/ok3sJ

    This seems like a cache issue to me, so I've tried the following in various incarnations along with the setVisible(false) on the items/item group, removing items from scene, and unloading tiles from memory:
    QGraphicsItemGroup setCacheMode(QGraphicsItem::NoCache)
    QGraphicsView setCacheMode(QGraphicsView::CacheNone)
    QGraphicsView invalidateScene()
    QGraphicsView resetCachedContent()
    QGraphicsItemGroup update()
    QGraphicsView update()
    QGraphicsView setViewportUpdateModel(QGraphicsView::FullViewportUpdate);

    I'm really at a loss as to what to try next. I've verified that I see this problem in both Nvidia systems with the Nvidia proprietary Linux driver, and on an ATI based gpu, running the ATI proprietary Linux driver.

    Any tips out there? I'm obviously no guru on QGraphicsViews.

    The QGraphicsView viewport is set to a QGLWidget. The "scene" is set to a QGraphicsScene. I'm thinking this has to be a cache issue. When I start the program up, the first flash of the map shows whatever the display was last time I ran the app, so it definitely seems like the system is caching the pixmaps, even though I'm telling the software not to.

  • Quick update. I've got it down to using a QGLWidget as the viewport for the graphicsview. If I stop setting the viewport to a QGLWidget, this problem doesn't occur.

    A bit of a slowdown in my map app, but I can probably live with it until I can figure out why I'm getting odd results with the QGLWidget.

    Anyone with tips, I'm all ears. Thanks in advance.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.