PDA

View Full Version : Trouble placing background images



WinchellChung
3rd July 2007, 18:55
I'm back with yet another stupid newbie question.

My client wants the Qt app to be re-sizable, with the main window having two states. Each state has a series of buttons on top of a background image. The background image is different for each state.

I'm having difficulty creating this with Qt Designer, as it does not seem to like objects that overlap.

I have a QtStackedWidget with two pages. On each page, I tried using a large QLabel with a pixmap along with a set of QPushButtons. But I cannot seem to convince Qt Designer to group the buttons in a QLayout that is nested inside the label, which itself is in a layout inside the Stacked Widget's page.

Either Qt Designer's layout buttons are disabled, or it creates a layout containing the label and buttons in a grid pattern. I cannot seem to get the buttons to lie on top of the label.

I can arrange everything as desired if I avoid layouts, but of course then if you re-size the window the elements do not dynamically reposition themselves.

Is there another technique I should be using? Is there another way to get a background image in each page besides using a label?

guilugi
4th July 2007, 09:22
Yes, you can use a stylesheet !

It's very elegant, and easy to use / change...

This should be something like this :

stack->setStyleSheet( "{background-image : url(your_image.png)}" );

Not sure of this syntax though, but that's the idea.

EDIT :
You can even specify the stylesheet through Qt Designer

WinchellChung
5th July 2007, 14:33
:o D'OH!! { slaps forehead }
Yes, why do I keep forgetting about style sheets? It worked like magic! Thanks!