Reputation: 255
I am using QStyleOptionButton in paint() method of my delegate implementation . How to set stylesheet and icon for the button created by QStyleOptionButton ?
I am able to set the icon , but the icon is set , left side of that button ..
i want to set the icon and stylesheet on the top of that button ..
Thankx in advance .
Upvotes: 1
Views: 1245
Reputation: 13130
You have to create real instance of QPushButton you want to style with unique object name. Then you may use it in qcss. If you want to inherit it's look'n'feel to QStyleOptionButton
you have to use initFrom(const QWidget * widget)
member of QStyleOptionButton
.
i.e.
MyCustomDelegate: QAbstractItemDelegate
{
Q_OBJECT
public:
MyCustomDelegate(...) { styleB = new QPushButton(); styleB->setObjectName("MyCustomDelegateButton"); }
private:
QPushButton * styleB;
};
And then in qcss you do
#MyCustomDelegateButton
{
background: green;
color: red;
}
This should work
Upvotes: 2