def paint(self, painter, option, index): opts = QStyleOptionProgressBar() opts.rect = option.rect opts.minimum = 1 opts.maximum = 100 opts.textVisible = True try: percent = int(index.model().data(index, Qt.DisplayRole)) except (TypeError, ValueError): percent = 0 opts.progress = percent opts.text = (_('Unavailable') if percent == 0 else '%d%%' % percent) QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
def paintEvent(self, event): ''' @param: event QPaintEvent ''' paint = QStylePainter(self) opt = QStyleOptionProgressBar() self._initStyleOption(opt) paint.drawControl(QStyle.CE_ProgressBar, opt) self._lastPaintedValue = self._value
def paint(self, painter, option, index): opts = QStyleOptionProgressBar() opts.rect = option.rect opts.minimum = 1 opts.maximum = 100 opts.textVisible = True try: percent = int(index.model().data(index, Qt.DisplayRole)) except (TypeError, ValueError): percent = 0 opts.progress = percent opts.text = (_('Unavailable') if percent == 0 else '%d%%'%percent) QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)