当前位置: 首页>>代码示例>>Python>>正文


Python QStyledItemDelegate.sizeHint方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QStyledItemDelegate.sizeHint方法的典型用法代码示例。如果您正苦于以下问题:Python QStyledItemDelegate.sizeHint方法的具体用法?Python QStyledItemDelegate.sizeHint怎么用?Python QStyledItemDelegate.sizeHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QStyledItemDelegate的用法示例。


在下文中一共展示了QStyledItemDelegate.sizeHint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
 def sizeHint(self, option, index):
     s = QStyledItemDelegate.sizeHint(self, option, index)
     if s.width() > 150:
         s.setWidth(150)
     elif s.width() < 50:
         s.setWidth(50)
     return s + QSize(18, 0)
开发者ID:TenKeyAngle,项目名称:manuskript,代码行数:9,代码来源:outlineDelegates.py

示例2: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
 def sizeHint(self, option, index):
     layer = index.data()
     if isinstance(layer, Layer):
         self._w.layer = layer
         self._w.channelSelector.setVisible(True)
         return self._w.sizeHint()
     else:
         return QStyledItemDelegate.sizeHint(self, option, index)
开发者ID:ilastik,项目名称:volumina,代码行数:10,代码来源:layerwidget.py

示例3: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
 def sizeHint(self, option, index):
     fm = option.fontMetrics
     if index.column() == residNum:
         return QSize(fm.width("9,999,999"), fm.height())
     if index.column() == residName:
         text = index.model().data(index)
         document = QTextDocument()
         document.setDefaultFont(option.font)
         document.setHtml(text)
         return QSize(document.idealWidth() + 5, fm.height())
     return QStyledItemDelegate.sizeHint(self, option, index)
开发者ID:hovo1990,项目名称:GROM,代码行数:13,代码来源:gro_model.py

示例4: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
    def sizeHint(self, option, index):
        """QStyledItemDelegate.sizeHint implementation
        """
        options = QStyleOptionViewItem(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())
开发者ID:Aldenis2112,项目名称:qutepart,代码行数:14,代码来源:htmldelegate.py

示例5: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
    def sizeHint(self, option, index):
        # s = QStyledItemDelegate.sizeHint(self, option, index)

        item = QModelIndex()
        for i in range(self.mdlPersos.rowCount()):
            if self.mdlPersos.ID(i) == index.data():
                item = self.mdlPersos.index(i, Perso.name.value)

        opt = QStyleOptionViewItem(option)
        self.initStyleOption(opt, item)
        s = QStyledItemDelegate.sizeHint(self, opt, item)

        if s.width() > 200:
            s.setWidth(200)
        elif s.width() < 100:
            s.setWidth(100)
        return s + QSize(18, 0)
开发者ID:georgehank,项目名称:manuskript,代码行数:19,代码来源:outlineDelegates.py

示例6: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
    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 - QStyleOptionViewItem
            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
开发者ID:patrickatamaniuk,项目名称:moneyguru,代码行数:26,代码来源:item_delegate.py

示例7: sizeHint

# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import sizeHint [as 别名]
 def sizeHint(self, option, index):
     s = QStyledItemDelegate.sizeHint(self, option, index)
     if s.width() < 200:
         s.setWidth(200)
     return s
开发者ID:TenKeyAngle,项目名称:manuskript,代码行数:7,代码来源:plotDelegate.py


注:本文中的PyQt5.QtWidgets.QStyledItemDelegate.sizeHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。