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:
//Brush erstellen und Image als Brush setzen
brushBackground
= new QBrush( *loadedPicture
);
//Hintergrund-Brush der Zeichenfläche zuweisen
this->setBackgroundBrush( *brushBackground );
QImage *loadedPicture = new QImage( sPathOfPicture );
//Brush erstellen und Image als Brush setzen
brushBackground = new QBrush( *loadedPicture );
//Hintergrund-Brush der Zeichenfläche zuweisen
this->setBackgroundBrush( *brushBackground );
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!
Bookmarks