class ProgressBarDelegate(QAbstractItemDelegate):
def sizeHint(self, option, index):
return QSize(120, 30)
def paint(self, painter, option, index):
opts = QStyleOptionProgressBarV2()
opts.rect = option.rect
opts.minimum = 1
opts.maximum = 100
opts.textVisible = True
percent, ok = index.model().data(index, Qt.DisplayRole).toInt()
if not ok:
percent = 0
opts.progress = percent
opts.text = QString(_('Unavailable') if percent == 0 else
'%d%%'%percent)
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)On Thursday 16 October 2008 09:50:54 Wim Verhavert wrote: > Dear all, > > I want to do something in PyQT I have seen many times in other > applications: A QTableView where the last column contains a QProgressbar. > Basically I want to implement some kind of cue where each item is processed > which can take a while. To give some visual feedback I want to display > a progressbar in the last column. This would allow sorting on progress > and such. > I have the book 'Rapid GUI Programming with Python and Qt' by Mark > Summerfield at hand which contains a section about custom delegates. I > have done similar things in the past, but somehow I'm not able to > translate this into the thing I want to do. Is there somebody out > there that could give me a head start? > > I think it will need to create a custom delegate and override the > paint method. But how? How do I paint a progressbar? Do I have to do > this from scratch, i.e. filling a part of the cell with a color, or > can I use a QProgressbar? Any suggestions are welcome. > > Cheers! > > Wim > _______________________________________________ > PyQt mailing list [email protected] > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > !DSPAM:3,48f771b131535171880063! -- _____________________________________ Kovid Goyal MC 452-48 California Institute of Technology 1200 E California Blvd Pasadena, CA 91125 cell : +01 626 390 8699 office: +01 626 395 6595 (449 Lauritsen) email : [EMAIL PROTECTED] web : http://www.kovidgoyal.net _____________________________________
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
