@SumanthReddy попробуйте с:
ал создавать плагин для QGIS 3, и мой плагин требует наличия индикаторов прогресса в QTableView. Я пытаюсь выяснить, как добавить столбец индикаторов выполнения в моем QTableView в PyQt5. Но я не смог найти какой-либо соответствующий код или ресурсы, касающиеся моей проблемы. Пожалуйста, помогите мне в этом.
Мой стол
w= self.tasklist_tabv
delegate = ProgressDelegate(w)
w.setItemDelegateForColumn(2, delegate)
w.setHorizontalHeaderLabels(["ID", "Name", "Progress"])
for r, (_id, _name, _progress) in enumerate(data):
it_id = QtGui.QTableWidgetItem(_id)
it_name = QtGui.QTableWidgetItem(_name)
it_progress = QtGui.QTableWidgetItem()
chkBoxItem = QtGui.QTableWidgetItem()
chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
it_progress.setData(QtCore.Qt.DisplayRole+1000, _progress)
w.insertRow(w.rowCount())
for c, item in enumerate((it_id, it_name, it_progress)):
w.setItem(r, c, item)
for c, item in enumerate((it_id, it_name, chkBoxItem)):
w.setItem(r, c+1, item)
class ProgressDelegate(QtGui.QStyledItemDelegate):
def paint(self, painter, option, index):
progress = index.data(QtCore.Qt.DisplayRole+1000)
opt = QtGui.QStyleOptionProgressBar()
opt.rect = option.rect
opt.minimum = 0
opt.maximum = 100
opt.progress = progress
opt.text = "{}%".format(progress)
opt.textVisible = True
QtGui.QApplication.style().drawControl(QtGui.QStyle.CE_ProgressBar, opt, painter)