def sizeHint(self, Option, Index): #if Index.column() == 0: #print("Sizehinting", Option, Index) #QStyleOptionViewItemV4.decorationSize return QStyledItemDelegate.sizeHint(self, Option, Index)
def sizeHint(self, option, index): option = QStyleOptionViewItemV4(option) self.initStyleOption(option, index) size = QStyledItemDelegate.sizeHint(self, option, index) # TODO: get the default QMenu item height from the current style. size.setHeight(max(size.height(), 25)) return size
def sizeHint(self, option, index): s = QStyledItemDelegate.sizeHint(self, option, index) radio_height = QApplication.style().pixelMetric( QStyle.PM_ExclusiveIndicatorHeight, option) check_height = QApplication.style().pixelMetric( QStyle.PM_IndicatorHeight, option) s.setHeight(max(s.height(), radio_height, check_height)) return s
def sizeHint(self, option, index): layer = index.data().toPyObject() if isinstance(layer, Layer): self._layerPainter.layer = layer mode = "Expanded" if self.expandAll or self._view.currentIndex() == index else 'ReadOnly' return self._layerPainter.sizeHint( mode ) else: return QStyledItemDelegate.sizeHint(self, option, index)
def sizeHint(self, option, index): size = QStyledItemDelegate.sizeHint(self, option, index) parent = self.parent() item = parent.itemFromIndex(index) widget = parent.itemWidget(item, 0) if widget: size = QSize(size.width(), widget.sizeHint().height() / 2) return size
def sizeHint(self, option, index): layer = index.data().toPyObject() if isinstance(layer, Layer): self._w.layer = layer self._w.channelSelector.setVisible(True) return self._w.sizeHint() else: return QStyledItemDelegate.sizeHint(self, option, index)
def sizeHint(self, option, index): fm = option.fontMetrics if index.column() == TEU: return QSize(fm.width("9,999,999"), fm.height()) if index.column() == DESCRIPTION: text = index.model().data(index).toString() document = QTextDocument() document.setDefaultFont(option.font) document.setHtml(text) return QSize(document.idealWidth() + 5, fm.height()) return QStyledItemDelegate.sizeHint(self, option, index)
def sizeHint( self, option, index ): u""" El tamaño sugerido de los datos en el modelo """ fm = option.fontMetrics if index.column() == DESCRIPCION: return QSize( 250, fm.height() ) else: return QSize( 150, fm.height() ) return QStyledItemDelegate.sizeHint( self, option, index )
def sizeHint(self, option, index): """QStyledItemDelegate.sizeHint implementation """ options = QStyleOptionViewItemV4(option) self.initStyleOption(options,index) doc = QTextDocument() doc.setDocumentMargin(1) # bad long (multiline) strings processing doc.setTextWidth(options.rect.width()) doc.setHtml(options.text) return QSize(doc.idealWidth(), QStyledItemDelegate.sizeHint(self, option, index).height())
def sizeHint( self, option, index ): fm = option.fontMetrics if index.column() in ( NOMBRE, TELEFONO, RUC, EMAIL ): text = index.model().data( index ).toString() document = QTextDocument() document.setDefaultFont( option.font ) document.setHtml( text ) return QSize( document.idealWidth() + 5, fm.height() ) elif index.column() == ACTIVO: return QSize( fm.width( "9" ), fm.height() ) else: return QStyledItemDelegate.sizeHint( self, option, index )
def sizeHint( self, option, index ): u""" El tamaño sugerido de los datos en el modelo """ fm = option.fontMetrics if index.column() == CODCUENTA: return QSize( 130, fm.height() ) if index.column() == NCUENTA: return QSize( 250, fm.height() ) if index.column() == MONTO: return QSize( 80, fm.height() ) return QStyledItemDelegate.sizeHint( self, option, index )
def sizeHint(self, option, index): sizeHint = QStyledItemDelegate.sizeHint(self, option, index) if self.parent() != None: # QItemDelegate добавляет 2 * ширину рамки (хотя мы её и не рисуем), плюс нужно учесть # ширину скроллбара. style = QApplication.style() ff = style.pixelMetric(QStyle.PM_FocusFrameHMargin, option) sb = style.pixelMetric(QStyle.PM_ScrollBarExtent, option) sizeHint.setWidth(min(sizeHint.width(), self.parent().width()) - 2 * ff - sb) if settings.oneLineEntry() or not index.parent().isValid(): sizeHint.setHeight(sizeHint.height() + 2 * settings.entryTopBottomMargin()) return sizeHint else: return QSize(sizeHint.width(), 2 * sizeHint.height())
def sizeHint(self, option, index): s = QStyledItemDelegate.sizeHint(self, option, index) # sizeHint is for some reason only called once, so set # size globally # if index.data(CheckableItemDelegate.CheckTypeRole): # # Determine size of check buttons in current style # #noinspection PyArgumentList # button_height = QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorHeight, option) # # Ensure that row is tall enough to draw check button # print button_height # s.setHeight(max(s.height(), button_height)) radio_height = QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorHeight, option) check_height = QApplication.style().pixelMetric(QStyle.PM_IndicatorHeight, option) s.setHeight(max(s.height(), radio_height, check_height)) return s
def sizeHint(self, option, index): """ This method is re-implemented because Description column is using HTML, it must return the exactly number of characters for presentation purpose rather than the number of HTML raw characters. """ fm = option.fontMetrics if index.column() == TEU: return QSize(fm.width("9,999,999"), fm.height()) if index.column() == DESCRIPTION: text = index.model().data(index).toString() document = QTextDocument() document.setDefaultFont(option.font) document.setHtml(text) return QSize(document.idealWidth() + 5, fm.height()) return QStyledItemDelegate.sizeHint(self, option, index)
def sizeHint(self, option, index): s = QStyledItemDelegate.sizeHint(self, option, index) # sizeHint is for some reason only called once, so set # size globally #if index.data(CheckableItemDelegate.CheckTypeRole): # # Determine size of check buttons in current style # #noinspection PyArgumentList # button_height = QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorHeight, option) # # Ensure that row is tall enough to draw check button # print button_height # s.setHeight(max(s.height(), button_height)) radio_height = QApplication.style().pixelMetric( QStyle.PM_ExclusiveIndicatorHeight, option) check_height = QApplication.style().pixelMetric( QStyle.PM_IndicatorHeight, option) s.setHeight(max(s.height(), radio_height, check_height)) return s
def sizeHint(self, option, index): """Returns a QSize bounding box of the area required to paint the data in the model at the index. Returns the size of the bounding box of the area required to paint the data in the model at the specified index. This is the sum of decoration pixmap widths, and the sizeHint provided by the custom value_painter if it exists. Args: option - QStyleOptionViewItemV4 index - QModelIndex Returns: A QSize bounding box of the size required to paint the value of the data in the model plus decorations. """ value_painter = self._get_value_painter(index) if value_painter is None: return QStyledItemDelegate.sizeHint(self, option, index) decs = self._get_decorations(index, bool(option.state & QStyle.State_Selected)) pix_widths = [dec.pixmap.width() for dec in decs] size = value_painter.sizeHint(option, index) size.setWidth(size.width() + sum(pix_widths)) return size
def sizeHint(self, option, index): " Returns the size hint in which the only height matters " origSize = QStyledItemDelegate.sizeHint(self, option, index) self.lastHeight = origSize.height() + self.delta origSize.setHeight(self.lastHeight) return origSize
def sizeHint(self, option, index): size = QStyledItemDelegate.sizeHint(self, option, index) return QSize(size.width(), size.height() + 4)
def sizeHint(self, option, index): return QStyledItemDelegate.sizeHint(self, option, index)
def sizeHint( self, option, index ): " Returns the size hint in which the only height matters " origSize = QStyledItemDelegate.sizeHint( self, option, index ) self.lastHeight = origSize.height() + self.delta origSize.setHeight( self.lastHeight ) return origSize
def sizeHint( self, option, index ): fm = option.fontMetrics if index.column() == NFAC: return QSize( 250, fm.height() ) return QStyledItemDelegate.sizeHint( self, option, index )