Hey there,

I have a rather simple question. I have a QGraphicsView where I want to paint custom things on the background (which don't change size when the view is scaled).
For testing purposes I started testing with painting "Test" in drawBackground:

Qt Code:
  1. void View::drawBackground(QPainter *painter, const QRectF &rect)
  2. {
  3. painter->save();
  4. painter->setWorldMatrixEnabled(false);
  5. painter->drawText(this->rect().center(), "Test");
  6. painter->restore();
  7. }
To copy to clipboard, switch view to plain text mode 
To see that the scaling actually works, I've added a QGraphicsTextItem.
Now what happens, is that when I move the graphicsView and my previously painted "Test" goes outside the viewport and then goes back in, it's gone (or partially gone, if I only partially moved it outside the viewport).

QGraphicsView::setCacheMode(CacheNone) is set and I also tried playing around with optimization flags but nothing seemed to work.

Can you guys give me a hint on what's going wrong? I need to use custom painting, because there's going to be a world map painted and stuff...

Here are some screenshots for better understanding what my problem is: