Hi,

I'm coding a programm with a QGraphicsScene and a QGraphicsView of course.
In the GraphicsView I want to use a picture as the backgroundBrush of this View.

I have coded a widget to choose a picture with a QFileDialog. Now you can choose a picture and it will shows on the background of the view...it works fine!

But I have a problem:

The picture fills the complete background. If the background/the View greater than the picture (I have implemented a Zoom too), the picture will repeated on the complete background. But I want that the picture will show only one time at the background, the other space of the background shall be colored in white.

Here is my code:

Qt Code:
  1. QImage *loadedPicture = new QImage( sPathOfPicture );
  2.  
  3. //Brush erstellen und Image als Brush setzen
  4. brushBackground = new QBrush( *loadedPicture );
  5.  
  6. //Hintergrund-Brush der Zeichenfläche zuweisen
  7. this->setBackgroundBrush( *brushBackground );
  8. this->setCacheMode(QGraphicsView::CacheBackground);
To copy to clipboard, switch view to plain text mode 

I have googled about this problem, but I can't find any solutions except like "You can reimplement the drawBackground-Methode", etc. but because I'm a newbie, I don't know how I have to do that.

Please, can anyone help me with my problem!

Thanks

PS.: I hope you can read my bad english!