1

I created a new class clickable label which inherits from QLabel and acts as a sort of "push button".

I would like to use background images as the button it self. This way I could also change the background image for various states (disabled, clicked, released).

How can I either specify a style sheet to only change the attributes for that label, or change a property/attribute of Qlabel somehow? (I know the style sheet would be background-image url(xxx) but it would change all my buttons to that image in my custom class)

Thanks

Jim
  • 9
  • 3
  • Take a look [here](http://stackoverflow.com/questions/6582245/qpushbutton-settext-problem-in-qt), I think that making *your* button on to of `QAbstractButton` is a decent solution – Thomas Vincent Jul 06 '11 at 20:22

1 Answers1

0

You can target a specific widget by assigning a style sheet just to that particular widget by calling setStyleSheet(const QString & styleSheet) on it.

If you want to use a stylesheet further up the widget hierarcy, or at the application level, you can target a particular widget by using a css selector like this:

QWidget[objectName="myObject"]

You would need to make sure that the widget in question has its ojbect name set using setObjectName("myObject").

Arnold Spence
  • 21,942
  • 7
  • 74
  • 67