本文整理汇总了Python中AnyQt.QtCore.QRectF.setSize方法的典型用法代码示例。如果您正苦于以下问题:Python QRectF.setSize方法的具体用法?Python QRectF.setSize怎么用?Python QRectF.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRectF
的用法示例。
在下文中一共展示了QRectF.setSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from AnyQt.QtCore import QRectF [as 别名]
# 或者: from AnyQt.QtCore.QRectF import setSize [as 别名]
def paint(self, painter, option, widget=None):
if not self.__icon.isNull():
if option.state & QStyle.State_Selected:
mode = QIcon.Selected
elif option.state & QStyle.State_Enabled:
mode = QIcon.Normal
elif option.state & QStyle.State_Active:
mode = QIcon.Active
else:
mode = QIcon.Disabled
transform = self.sceneTransform()
if widget is not None:
# 'widget' is the QGraphicsView.viewport()
view = widget.parent()
if isinstance(view, QGraphicsView):
# Combine the scene transform with the view transform.
view_transform = view.transform()
transform = view_transform * view_transform
lod = option.levelOfDetailFromTransform(transform)
w, h = self.__iconSize.width(), self.__iconSize.height()
target = QRectF(0, 0, w, h)
source = QRectF(0, 0, w * lod, w * lod).toRect()
# The actual size of the requested pixmap can be smaller.
size = self.__icon.actualSize(source.size(), mode=mode)
source.setSize(size)
pixmap = self.__icon.pixmap(source.size(), mode=mode)
painter.setRenderHint(
QPainter.SmoothPixmapTransform,
self.__transformationMode == Qt.SmoothTransformation
)
painter.drawPixmap(target, pixmap, QRectF(source))