PDA

View Full Version : BG image on QPushButton using style sheets??



JimDaniel
12th September 2007, 15:25
Hi, our project is using style sheets to set the menu background like so:


menu->setStyleSheet("QWidget { background: url(C://lobby_bg.jpg) }");

This works fine, but now we want to make our QPushButtons have an image for a background, so we tried this:


button->setStyleSheet("QPushButton { background: url(C://lobbybuttontest.jpg) }");

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.

momesana
12th September 2007, 20:01
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/06/04/backgrounds-pseudo-states-qt-43-style-sheets/#comments

JimDaniel
13th September 2007, 03:31
Thanks for the help! That link has just the information I've been looking for...