Использование PyQt5 для настройки делегата редактора в качестве QDoubleSpinBox:
class MoneyDelegate(QStyledItemDelegate):
def initStyleOption(self, option, index):
super(MoneyDelegate, self).initStyleOption(option, index)
val = float(index.data())
option.text = '${:,.2f}'.format(val)
option.displayAlignment = Qt.AlignVCenter | Qt.AlignRight
def createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex):
super(MoneyDelegate, self).createEditor(QWidget, QStyleOptionViewItem, QModelIndex)
editor = QDoubleSpinBox(self)
editor.setMinimum(.01)
editor.setMaximum(999999.99)
return(editor)
В моем классе QTableWidget:
self.tbl_View.setItemDelegateForColumn(2, MoneyDelegate(self))
У меня проблема в том, что редактор отображается в верхнем левом углу экрана в виде отдельного диалога. Что мне здесь не хватает?