Results 1 to 3 of 3

Thread: Setting background image of QFrame

  1. #1
    Join Date
    Oct 2006
    Location
    Austin, Texas, USA
    Posts
    18
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Setting background image of QFrame

    Hello! I'm having some trouble getting a background image to show up in a QFrame using Qt 4.2.2. Here is a snippit of the code that I have:

    Qt Code:
    1. ui.frame->setStyleSheet("background-image: url(:/images/menu_background.png);"
    2. "background-repeat: repeat;");
    To copy to clipboard, switch view to plain text mode 

    The image being referenced is pulled in via a QRC file I have in the project. However, for some reason the image isn't showing up... Is there something I'm doing wrong?

    Here's the contents of the QRC file for reference:
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/" >
    3. <file>images/menu_background.png</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

    Thanks!

    - Clay

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Setting background image of QFrame

    Have you noticed the note:
    For QFrame and its subclasses, you must set the QFrame::frameStyle property to QFrame::StyledPanel; otherwise, the background attribute will not be respected.
    J-P Nurmi

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

    Cupidvogel (2nd June 2015)

  4. #3
    Join Date
    Oct 2006
    Location
    Austin, Texas, USA
    Posts
    18
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Setting background image of QFrame

    Ah, you're very right - I missed seeing that comment when I was skimming through the documentation (need to work on my reading comprehension... *sigh*).

    Originally I had the QFrame::frameShape set to QFrame::NoFrame and the QFrame::frameShadow set to QFrame::Plain. When I changed it back to QFrame::StyledPanel I also had to change the QFrame::frameShadow to QFrame::Raised in order for the background image to show up properly.

    Thanks!

Similar Threads

  1. Replies: 3
    Last Post: 18th May 2012, 10:12
  2. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  3. Background image on popup menu item
    By MarkoSan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th June 2006, 05:55
  4. QFrame and its background
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 20:32
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 13:02

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.