PDA

View Full Version : Stylesheeting and QStyle::drawControl() - possible?



dimuz
16th October 2007, 10:08
Hello, guys!

This time I want to draw a progress bar in one of QTreeView cells.
Well, I already have the code which does this - just created my own QItemDelegate which uses QStyle::drawControl().

And the question: I need that progress bar to be stylable. I mean - stylable with stylesheets.
Is there a way to do so?

Something like setting QApplication::setStylesheet("QProgressBar {...}")?
First, I don't know if this'll work (I guess I should just try)
Second - I don't want to apply this style to all of my progress bars, just the one rendered in QTreeView.

Any hints, suggestions?
Thanks in advance!

wysota
21st October 2007, 00:21
Will that work? No idea.... should work, because style() should return a pointer to the stylesheet style if a stylesheet is applied. If it works, then try applying the stylesheet (with proper selectors) on the view widget or on the viewport widget. Assuming you don't have any real progress bar widgets in your view only the fake bars should be affected.

dimuz
22nd October 2007, 09:30
In case you interested, this did not work :)
I didn't investigate further - I tried and seen no results.
So instead I just ended up using QProgressBar as a persistent editor - ala fake one - which doesn't actually used edit anything (it's a progress bar ;)).
I just reimplemented createEditor() & friends in my delegate and call QTreeView::openPersistentEditor() for each row when new rows are added.