本文整理汇总了Python中AnyQt.QtCore.QRect.y方法的典型用法代码示例。如果您正苦于以下问题:Python QRect.y方法的具体用法?Python QRect.y怎么用?Python QRect.y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRect
的用法示例。
在下文中一共展示了QRect.y方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import y [as 别名]
def paint(self, painter, option, index):
rect = QRect(option.rect)
is_selected = index.data(VariableSelectionModel.IsSelected)
if option.state & QStyle.State_MouseOver:
txt = [" Add ", " Remove "][is_selected]
txtw = painter.fontMetrics().width(txt)
painter.save()
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#ccc"))
brect = QRect(rect.x() + rect.width() - 8 - txtw, rect.y(),
txtw, rect.height())
painter.drawRoundedRect(brect, 4, 4)
painter.restore()
painter.drawText(brect, Qt.AlignCenter, txt)
painter.save()
double_pen = painter.pen()
double_pen.setWidth(2 * double_pen.width())
if is_selected:
next = index.sibling(index.row() + 1, index.column())
if not next.isValid():
painter.setPen(double_pen)
painter.drawLine(rect.bottomLeft(), rect.bottomRight())
elif not next.data(VariableSelectionModel.IsSelected):
painter.drawLine(rect.bottomLeft(), rect.bottomRight())
elif not index.row():
down = QPoint(0, painter.pen().width())
painter.setPen(double_pen)
painter.drawLine(rect.topLeft() + down, rect.topRight() + down)
else:
prev = index.sibling(index.row() - 1, index.column())
if prev.data(VariableSelectionModel.IsSelected):
painter.drawLine(rect.topLeft(), rect.topRight())
painter.restore()
super().paint(painter, option, index)
示例2: __layout
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import y [as 别名]
def __layout(self):
# position itself over `widget`
widget = self.__widget
if widget is None:
return
alignment = self.__alignment
policy = self.sizePolicy()
if widget.isWindow():
bounds = widget.geometry()
else:
bounds = QRect(widget.mapToGlobal(QPoint(0, 0)),
widget.size())
if self.isWindow():
bounds = bounds
else:
bounds = QRect(self.parent().mapFromGlobal(bounds.topLeft()),
bounds.size())
sh = self.sizeHint()
minsh = self.minimumSizeHint()
minsize = self.minimumSize()
if minsize.isNull():
minsize = minsh
maxsize = bounds.size().boundedTo(self.maximumSize())
minsize = minsize.boundedTo(maxsize)
effectivesh = sh.expandedTo(minsize).boundedTo(maxsize)
hpolicy = policy.horizontalPolicy()
vpolicy = policy.verticalPolicy()
def getsize(hint, minimum, maximum, policy):
if policy == QSizePolicy.Ignored:
return maximum
elif policy & QSizePolicy.ExpandFlag:
return maximum
else:
return max(hint, minimum)
width = getsize(effectivesh.width(), minsize.width(),
maxsize.width(), hpolicy)
heightforw = self.heightForWidth(width)
if heightforw > 0:
height = getsize(heightforw, minsize.height(),
maxsize.height(), vpolicy)
else:
height = getsize(effectivesh.height(), minsize.height(),
maxsize.height(), vpolicy)
size = QSize(width, height)
if alignment & Qt.AlignLeft:
x = bounds.x()
elif alignment & Qt.AlignRight:
x = bounds.right() - size.width()
else:
x = bounds.x() + max(0, bounds.width() - size.width()) // 2
if alignment & Qt.AlignTop:
y = bounds.y()
elif alignment & Qt.AlignBottom:
y = bounds.bottom() - size.height()
else:
y = bounds.y() + max(0, bounds.height() - size.height()) // 2
geom = QRect(QPoint(x, y), size)
self.setGeometry(geom)