PDA

View Full Version : QStyledItemDelegate paint QPushButton with stylesheet



Talei
2nd July 2011, 19:37
Hello,
I struggle with painting QPushButton with inherited styleSheet in custom delegate.
Delegate parent is TreeView with styleSheet.

The way I paint it in my QStyledItemDelegate.


void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionButton pb_Style;
pb_Style.state |= QStyle::State_Raised | QStyle::State_Enabled | option.state;

QRect pbRect = option.rect;
...

pb_Style.rect = pbRect;
pb_Style.text = QString();

style->drawControl(QStyle::CE_PushButton, &pb_Style, painter, qobject_cast<QWidget *>(this->parent()) );
}

In short I don't know how to paint QPushButton with inherited styleSheet from the view.
Any suggestions are more then welcome.

Talei
3rd July 2011, 04:23
SOLVED:
Paint actual widget does the trick, my bad.

Geefer
17th July 2011, 14:14
SOLVED:
Paint actual widget does the trick, my bad.

Can you explain exactly what you mean by this? Perhaps with an example?

I am seeing a similar problem with a QProgressBar not being painted with the stylesheet set on my QTreeWidget within my QStyledItemDelegate even though the stylesheet works fine for true QProgressBar widgets.