Results 1 to 3 of 3

Thread: BG image on QPushButton using style sheets??

  1. #1
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default BG image on QPushButton using style sheets??

    Hi, our project is using style sheets to set the menu background like so:
    Qt Code:
    1. menu->setStyleSheet("QWidget { background: url(C://lobby_bg.jpg) }");
    To copy to clipboard, switch view to plain text mode 
    This works fine, but now we want to make our QPushButtons have an image for a background, so we tried this:
    Qt Code:
    1. button->setStyleSheet("QPushButton { background: url(C://lobbybuttontest.jpg) }");
    To copy to clipboard, switch view to plain text mode 
    But this doesn't work. According to the documentation, QPushButton should be able to use "background: url()"

    Does anyone have any ideas why its not working?

    Also, is this an acceptable way to do something like this. In the documentation I read about creating your own QStyle, but to be honest it seems very involved and confusing.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: BG image on QPushButton using style sheets??

    You have to add border:none; to your stylesheet. Then the background will be shown. The native Qt-4.3 borders are drawn over the background-image. Read the final post on this thread: http://labs.trolltech.com/blogs/2007...eets/#comments

  3. #3
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: BG image on QPushButton using style sheets??

    Thanks for the help! That link has just the information I've been looking for...

Similar Threads

  1. Adding Image to QPushButton
    By Seema Rao in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 10:06
  2. CSS Style Sheets - Further Development?
    By bjoernbg in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 16:59
  3. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 18:03
  4. style sheets
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2007, 16:14
  5. Qt Style Sheets Problems with QDialog
    By Lykurg in forum Qt Programming
    Replies: 3
    Last Post: 5th November 2006, 15:43

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.