本文整理汇总了Python中PyQt5.QtWidgets.QStyledItemDelegate.updateEditorGeometry方法的典型用法代码示例。如果您正苦于以下问题:Python QStyledItemDelegate.updateEditorGeometry方法的具体用法?Python QStyledItemDelegate.updateEditorGeometry怎么用?Python QStyledItemDelegate.updateEditorGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStyledItemDelegate
的用法示例。
在下文中一共展示了QStyledItemDelegate.updateEditorGeometry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateEditorGeometry
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import updateEditorGeometry [as 别名]
def updateEditorGeometry(self, editor: QWidget,
option: QStyleOptionViewItem,
model_index: QModelIndex):
column = model_index.column()
if column == NAME_COL:
editor.setGeometry(option.rect)
# elif column == VISIBLE_COL:
# rect = QRect(option.rect)
# delta = option.rect.width() / 2 - 9
# rect.setX(option.rect.x() + delta) # Hack to center the checkbox
# editor.setGeometry(rect)
# elif column == COLOR_COL:
# editor.setGeometry(option.rect)
else:
QStyledItemDelegate.updateEditorGeometry(self, editor, option, model_index)
示例2: updateEditorGeometry
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import updateEditorGeometry [as 别名]
def updateEditorGeometry(self, editor: QWidget,
option: QStyleOptionViewItem,
model_index: QModelIndex):
"""
Args:
editor: Description
option: Description
model_index: Description
"""
column = model_index.column()
if column == 0:
editor.setGeometry(option.rect)
elif column == 1:
value = model_index.model().data(model_index, Qt.EditRole)
data_type = type(value)
if data_type is bool:
rect = QRect(option.rect)
delta = option.rect.width() / 2 - 9
rect.setX(option.rect.x() + delta) # Hack to center the checkbox
editor.setGeometry(rect)
else:
editor.setGeometry(option.rect)
else:
QStyledItemDelegate.updateEditorGeometry(self, editor, option, model_index)
示例3: updateEditorGeometry
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import updateEditorGeometry [as 别名]
def updateEditorGeometry(self, editor, option, index):
if index.column() in DATE_TIME_COLUMN_LIST:
editor.setGeometry(option.rect)
else:
return QStyledItemDelegate.updateEditorGeometry(self, editor, option, index)