本文整理汇总了Python中PyQt4.QtGui.QItemDelegate.sizeHint方法的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate.sizeHint方法的具体用法?Python QItemDelegate.sizeHint怎么用?Python QItemDelegate.sizeHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QItemDelegate
的用法示例。
在下文中一共展示了QItemDelegate.sizeHint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sizeHint
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import sizeHint [as 别名]
def sizeHint(self, option, index):
fm = option.fontMetrics
if index.column() in (MOD1, MOD2, MOD3):
if self.mod is None:
w = 0
for mod in self.modifiers:
cw = fm.width(mod)
if cw > w:
w = cw
self.mod = mod
else:
w = fm.width(self.mod)
return QSize(w+20, fm.height())
elif index.column() == KEY:
if self.key is None:
w = 0
for key in self.keys:
cw = fm.width(key)
if cw > w:
w = cw
self.key = key
else:
w = fm.width(self.key)
return QSize(w+20, fm.height())
return QItemDelegate.sizeHint(self, option, index)
示例2: sizeHint
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import sizeHint [as 别名]
def sizeHint(self, option, index):
fm = option.fontMetrics
if index.column() in (SRC_ADDR, DST_ADDR):
text = index.model().data(index).toString()
document = QTextDocument()
document.setDefaultFont(option.font)
document.setHtml(text)
#document.setPageSize(option.rect.size())
return QSize(document.idealWidth() + 5, 1.3 * fm.height())
return QItemDelegate.sizeHint(self, option, index)
示例3: sizeHint
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import sizeHint [as 别名]
def sizeHint(self, option, index):
if index.column() is self._column:
return QSize(option.rect.size().width(), 25)
return QItemDelegate.sizeHint(self, option, index)
示例4: sizeHint
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import sizeHint [as 别名]
def sizeHint( self, option, index ):
" Returns the size hint in which the only height matters "
origSize = QItemDelegate.sizeHint( self, option, index )
self.lastHeight = origSize.height() + self.delta
origSize.setHeight( self.lastHeight )
return origSize
示例5: sizeHint
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import sizeHint [as 别名]
def sizeHint(self, opt, index):
option = opt;
sz = QItemDelegate.sizeHint(self, opt, index) + QSize(2, 2)
return sz