本文整理汇总了Python中PyQt4.QtGui.QItemDelegate类的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate类的具体用法?Python QItemDelegate怎么用?Python QItemDelegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QItemDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setModelData
def setModelData(self, editor, model, index):
""" save data from editor back to model """
if index.column() == self.column:
model.setData(index, editor.currentText())
else:
# use default
QItemDelegate.setModelData(self, editor, model, index)
示例2: __init__
def __init__(self, parent, itemsDict, column):
"""
Constructor
"""
QItemDelegate.__init__(self, parent)
self.itemsDict = itemsDict
self.column = column
示例3: __init__
def __init__(self, min, max, *args):
"""
min and max are the limits that the spin box can scroll to/accept.
"""
QItemDelegate.__init__(self, *args)
self.min = min
self.max = max
示例4: setModelData
def setModelData(self,editor,model,index):
"""Save value changes"""
if index.column() == 1:
value, ok = editor.itemData(editor.currentIndex()).toInt()
model.setData(index,QVariant(value),Qt.EditRole)
else:
QItemDelegate.setModelData(self,editor,model,index)
示例5: updateEditorGeometry
def updateEditorGeometry(self, editor, option, index):
''' PyQt API Method -- See the PyQt documentation for a description '''
if type(editor) == QComboBox:
editor.setGeometry(option.rect)
editor.showPopup()
else:
QItemDelegate.updateEditorGeometry(self, editor, option, index)
示例6: __init__
def __init__(self, columns=(), parent=None):
""" Construtor.
@param columns sequence of column numbers for LCD widgets
@param parent ancestor object
"""
QItemDelegate.__init__(self, parent)
self.columns = columns
示例7: __init__
def __init__(self, distObjects, parent=None):
"""Init TracepointModel
"""
QAbstractTableModel.__init__(self, parent)
QItemDelegate.__init__(self, parent)
self.tracepoints = []
self.distObjects = distObjects
self.connector = distObjects.gdb_connector
示例8: __init__
def __init__(self, parent_view):
"""
@param parent_view (QAbstractItemView): parent view for this item editor
"""
QItemDelegate.__init__(self, parent_view)
self.parent_view = parent_view
# List of database connection names. Used for populating the editor for a db_connection_hook
self.known_db_connection_names = []
示例9: setEditorData
def setEditorData(self, editor, index):
text = from_qvariant(index.model().data(index, Qt.DisplayRole), str)
if index.column() in (MOD1, MOD2, MOD3, KEY):
i = editor.findText(text)
if i == -1:
i = 0
editor.setCurrentIndex(i)
else:
QItemDelegate.setEditorData(self, editor, index)
示例10: setEditorData
def setEditorData(self, editor, index):
""" load data from model to editor """
m = index.model()
if index.column() == 1:
txt = m.data(index, Qt.DisplayRole)
editor.setEditText(txt)
else:
# use default
QItemDelegate.setEditorData(self, editor, index)
示例11: setModelData
def setModelData(self, editor, model, index):
""" save data from editor back to model """
if index.column() == 1:
model.setData(index, editor.currentText())
else:
# use default
QItemDelegate.setModelData(self, editor, model, index)
if index.column() == 0:
self.emit(SIGNAL("columnNameChanged()"))
示例12: setEditorData
def setEditorData(self,editor,index):
"""Set initial data for the editor"""
if index.column() == 0:
current = index.model().data(index,Qt.DisplayRole)
editor.setText(current)
elif index.column() == 1:
current = index.model().data(index,Qt.DisplayRole)
editor.setCurrentIndex(editor.findData(current))
else:
QItemDelegate.setEditorData(self,editor,index)
示例13: paint
def paint(self, painter, option, index):
if index.column() != 0:
QItemDelegate.paint(self, painter, option, index)
return
painter.fillRect(option.rect, option.palette.brush(QPalette.Base))
painter.setPen(QPen(option.palette.color(QPalette.Text)))
painter.drawText(option.rect.adjusted(4, 4, -4, -4),
Qt.TextShowMnemonic | Qt.AlignLeft | Qt.AlignVCenter,
index.data().toString())
示例14: paint
def paint(self, painter, option, index):
option.palette.setColor(
QPalette.Highlight,QColor(
index.data(Qt.BackgroundRole)).darker(107))
option.palette.setColor(
QPalette.HighlightedText,QColor(
index.data(Qt.ForegroundRole)).darker(115))
QItemDelegate.paint(self, painter, option, index)
if option.showDecorationSelected and \
(option.state & QStyle.State_Selected):
painter.drawRect(option.rect)
示例15: __init__
def __init__(self, parent=None, editable=True, **kwargs):
""":param parent: the parent object for the delegate
:param editable: a boolean indicating if the field associated to the delegate
is editable
"""
QItemDelegate.__init__(self, parent)
self.editable = editable
self.kwargs = kwargs
self._font_metrics = QtGui.QFontMetrics(QtGui.QApplication.font())
self._height = self._font_metrics.lineSpacing() + 10
self._width = self._font_metrics.averageCharWidth() * 20