<div dir="ltr"><div><div>hi,all,<br></div>I'm not sure it is appropriated to post this general question here, it not, please give me reminder.<br><br></div>I want to add progressbar into table widget with QStyleItemDelegate, it show progressbar on specific column, but the the progressbar does not fill full width of column. I also attached the screenshot to this mail.<br>
<br><br>following is my code snippet.<br><br>class CProgressBarDeletgate(QtGui.QStyledItemDelegate):<br><br> def paint(self, painter, optionViewItem, modelIndex):<br> progress_value = int(str(str(modelIndex.data().toPyObject())))<br>
progressBarOption = QtGui.QStyleOptionProgressBar()<br> progressBarOption.rect = optionViewItem.rect<br><br> progressBarOption.minimum = 0<br> progressBarOption.maximum = 100<br> progressBarOption.progress = progress_value<br>
progressBarOption.state = QtGui.QStyle.State_Enabled<br> progressBarOption.textVisible = True<br> QtGui.QApplication.style().drawControl(QtGui.QStyle.CE_ProgressBar, progressBarOption, painter)<br><br>
def __init__(self, parent=None):<br> super(CProgressBarDeletgate, self).__init__(parent)<br> <br clear="all"><div><div><div><br></div><div>following is tablewidget initialization code:<br> self._ui.tableWidget.setColumnCount(2)<br>
self._ui.tableWidget.setHorizontalHeaderLabels(['FileName','Progress'])<br> self._ui.tableWidget.setItemDelegateForColumn(1, CProgressBarDeletgate())<br> #self._ui.tableWidget.verticalHeader().setDefaultSectionSize()<br>
default_height = self._ui.tableWidget.verticalHeader().defaultSectionSize()<br> self._ui.tableWidget.verticalHeader().setDefaultSectionSize(default_height - 10)<br><br></div><div><br></div><div>Thank you so much~!<br>
<br></div><div>-- <br>------------<br>best regards<br><br>Wang Qi<br>
</div></div></div></div>