PDA

View Full Version : Graphics widget with background



ad5xj
23rd August 2007, 18:26
I am attempting to create a widget with a .PNG background and is drawn over with a rotating graphic. The problem is that I am unable to get both to occur at the same time. Either I get the background to show but I can't see what is drawn over it, or the objects that are drawn over the background show up but the background does not.

The documentation is confusing at best so I am seeking advice here. I have seen the examples for graphics view (colliding mice) and the code works as is. I just have not been able to get a similar effect to work in a widget of my own even using that exact code slightly modified to be a widget.

environment: WinXP and SUSE Linux 10.2 Qt 4.3.1 open source and MinGW with eclipse

marcel
23rd August 2007, 21:50
Well, you'll have to post the code, because it is impossible for someone to say what is wrong.

Regards

ad5xj
24th August 2007, 17:29
Well I was able to get the background to show using the stylesheet of the window. This put the graphic as a background for the window. It took some doing as there seems to be some bug in Qt 4 where you have to have a repaint event (even an empty one) for it to show. I discovered that this is not what I wanted anyway. This method displays the graphic with original dimensions and uses the window view area to crop if smaller or fill if larger. This action is like a MS Windows wallpaper image. Not what I had in mind.

I later ran across QScrollArea as a container for a control like a label. So I changed my project to have a QScrollArea that contains a label that has my graphic as a pixmap. The label widget is set to scale as the QScrollArea contents. Now each time the window resizes, so does the scroll area and the graphic in the label.

Hope this helps those who have run across this problem.