Results 1 to 3 of 3

Thread: Trouble placing background images

  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Trouble placing background images

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Trouble placing background images

    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

  3. The following user says thank you to guilugi for this useful post:

    WinchellChung (5th July 2007)

  4. #3
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Trouble placing background images

    D'OH!! { slaps forehead }
    Yes, why do I keep forgetting about style sheets? It worked like magic! Thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.