def sizeHint(self, option, index):
        sh = QItemDelegate.sizeHint(self, option, index)
        if index.isValid():
            data = index.data()
            h = 0
            offs = 0
            if isinstance(data, tuple) and len(data) > 0 and isinstance(
                    data[0], QPixmap):
                pix: QPixmap = data[0]
                h = pix.height()
                offs += 1

            fm = option.fontMetrics
            h1 = IconTextItemDelegate.CellVerticalMargin * 2 + IconTextItemDelegate.CellLinesMargin
            h1 += (fm.height() * 2) - 2
            h = max(h, h1)
            sh.setHeight(h)
        return sh
 def sizeHint(self, option: 'QStyleOptionViewItem', index):
     size: QSize = QItemDelegate.sizeHint(self, option, index)
     size.setWidth(100)
     return size
Esempio n. 3
0
 def sizeHint(self, option, index):
     delegate = self.delegates[index.column()]
     if delegate is not None:
         return delegate.sizeHint(option, index)
     else:
         return QItemDelegate.sizeHint(self, option, index)
 def sizeHint(self, option: 'QStyleOptionViewItem', index):
     if self.sizeCache is None:
         size: QSize = QItemDelegate.sizeHint(self, option, index)
         size.setWidth(100)
         self.sizeCache = size
     return self.sizeCache