PDA

View Full Version : QStyleOptionProgressBar customized



xEsk
11th November 2007, 18:12
Hi,

I'm painting a QProgressBar (using QStyleOptionProgressBar) into a QTreeView and works perfectly, ok, now I want customize this QProgressBar.

I made an a style sheet which works perfectly with a normal QProgressBar (not delegated), but I don't know how to set this Style Sheet to my delegated QProgressBar, because the QStyleOptionProgressBar don't have the styleSheet (http://doc.trolltech.com/4.3/qwidget.html#styleSheet-prop) property.

This is the style sheet used to customize the QProgressBar:


QProgressBar:horizontal {
border: 1px solid gray;
border-radius: 3px;
background: white;
padding: 1px;
}
QProgressBar::chunk:horizontal {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
}

Best regards, xEsk.

wysota
11th November 2007, 18:25
From what I know the default delegate in Qt4.3- might not support that feature. You might try applying the stylesheet on the view, but that probably won't work. You might also try applying the stylesheet to the view and using the view's style() to paint the progress bar. If that doesn't work, you'll need to get a snapshot of Qt4.4 with QStyledItemDelegate functionality and there it should work just fine (at least I hope so).

See the details here:http://labs.trolltech.com/blogs/2007/11/01/qstyleditemdelegate-styling-item-views/