本文整理汇总了Python中PyQt5.QtGui.QGuiApplication.font方法的典型用法代码示例。如果您正苦于以下问题:Python QGuiApplication.font方法的具体用法?Python QGuiApplication.font怎么用?Python QGuiApplication.font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QGuiApplication
的用法示例。
在下文中一共展示了QGuiApplication.font方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: syncWithMapObject
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import font [as 别名]
def syncWithMapObject(self, renderer):
nameVisible = self.mObject.isVisible() and self.mObject.name()!=''
self.setVisible(nameVisible)
if (not nameVisible):
return
metrics = QFontMetricsF(QGuiApplication.font())
boundingRect = metrics.boundingRect(self.mObject.name())
boundingRect.translate(-boundingRect.width() / 2, -labelDistance)
boundingRect.adjust(-labelMargin*2, -labelMargin, labelMargin*2, labelMargin)
pixelPos = renderer.pixelToScreenCoords_(self.mObject.position())
bounds = objectBounds(self.mObject, renderer)
# Adjust the bounding box for object rotation
transform = QTransform()
transform.translate(pixelPos.x(), pixelPos.y())
transform.rotate(self.mObject.rotation())
transform.translate(-pixelPos.x(), -pixelPos.y())
bounds = transform.mapRect(bounds)
# Center the object name on the object bounding box
pos = QPointF((bounds.left() + bounds.right()) / 2, bounds.top())
self.setPos(pos + self.mObject.objectGroup().offset())
if (self.mBoundingRect != boundingRect):
self.prepareGeometryChange()
self.mBoundingRect = boundingRect