本文整理汇总了Python中PyQt4.QtGui.QItemDelegate.setItemEditorFactory方法的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate.setItemEditorFactory方法的具体用法?Python QItemDelegate.setItemEditorFactory怎么用?Python QItemDelegate.setItemEditorFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QItemDelegate
的用法示例。
在下文中一共展示了QItemDelegate.setItemEditorFactory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditResDlg
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setItemEditorFactory [as 别名]
class EditResDlg(QDialog):
def __init__(self, images, scales, images_path, *args):
QDialog.__init__(self, *args)
cache = image_cache.cache
self.ui = Ui_EditResDlg()
self.ui.setupUi(self)
icons = []
for pth in images_path:
ico = QIcon(QPixmap.fromImage(cache.image(pth).scaled(QSize(64, 64), Qt.KeepAspectRatio)))
icons.append(ico)
self.model = ScaleModel(icons, images, scales)
self.ui.pixelSizes.setModel(self.model)
self.ui.pixelSizes.resizeColumnToContents(0)
self.ui.pixelSizes.resizeColumnToContents(1)
self.ui.pixelSizes.resizeColumnToContents(2)
self.item_delegate = QItemDelegate()
self.item_delegate.setItemEditorFactory(ScaleEditorFactory())
self.ui.pixelSizes.setItemDelegate(self.item_delegate)
self.ui.width.setValidator(QDoubleValidator(0, 1e300, 100, self))
self.ui.height.setValidator(QDoubleValidator(0, 1e300, 100, self))
# Find smallest scale
minx = inf
miny = inf
for img in scales:
sc = scales[img]
if sc[0] > 0 and sc[0] < minx:
minx = sc[0]
if sc[1] > 0 and sc[1] < miny:
miny = sc[1]
if minx == inf:
minx = 1e-6
if miny == inf:
miny = 1e-6
# And set the default unit
self.ui.unit.setCurrentIndex(self.model.findUnit(min(minx, miny)))
def __del__(self):
cleanQObject(self)
@pyqtSignature("int")
def on_unit_currentIndexChanged(self, idx):
self.model.setUnit(self.ui.unit.currentText())
@pyqtSignature("")
def on_setAll_clicked(self):
sel = self.ui.pixelSizes.selectionModel()
w = float(self.ui.width.text())
h = float(self.ui.height.text())
if sel.hasSelection():
self.model.setSubset(w, h, sel)
else:
self.model.setAll(w, h)