本文整理汇总了Python中PySide.QtGui.QFont.setPointSizeF方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setPointSizeF方法的具体用法?Python QFont.setPointSizeF怎么用?Python QFont.setPointSizeF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setPointSizeF方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setObjectText
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setPointSizeF [as 别名]
def setObjectText(self, strng):
"""
TOWRITE
:param `strng`: TOWRITE
:type `strng`: QString
"""
self.objText = strng
textPath = QPainterPath()
font = QFont()
font.setFamily(self.objTextFont)
font.setPointSizeF(self.objTextSize)
font.setBold(self.objTextBold)
font.setItalic(self.objTextItalic)
font.setUnderline(self.objTextUnderline)
font.setStrikeOut(self.objTextStrikeOut)
font.setOverline(self.objTextOverline)
textPath.addText(0., 0., font, strng)
# Translate the path based on the justification.
jRect = textPath.boundingRect() # QRectF
if self.objTextJustify == "Left": textPath.translate(-jRect.left(), 0)
elif self.objTextJustify == "Center": textPath.translate(-jRect.center().x(), 0)
elif self.objTextJustify == "Right": textPath.translate(-jRect.right(), 0)
elif self.objTextJustify == "Aligned": pass # TODO: TextSingleObject Aligned Justification
elif self.objTextJustify == "Middle": textPath.translate(-jRect.center())
elif self.objTextJustify == "Fit": pass # TODO: TextSingleObject Fit Justification
elif self.objTextJustify == "Top Left": textPath.translate(-jRect.topLeft())
elif self.objTextJustify == "Top Center": textPath.translate(-jRect.center().x(), -jRect.top())
elif self.objTextJustify == "Top Right": textPath.translate(-jRect.topRight())
elif self.objTextJustify == "Middle Left": textPath.translate(-jRect.left(), -jRect.top()/2.0)
elif self.objTextJustify == "Middle Center": textPath.translate(-jRect.center().x(), -jRect.top()/2.0)
elif self.objTextJustify == "Middle Right": textPath.translate(-jRect.right(), -jRect.top()/2.0)
elif self.objTextJustify == "Bottom Left": textPath.translate(-jRect.bottomLeft())
elif self.objTextJustify == "Bottom Center": textPath.translate(-jRect.center().x(), -jRect.bottom())
elif self.objTextJustify == "Bottom Right": textPath.translate(-jRect.bottomRight())
# Backward or Upside Down.
if self.objTextBackward or self.objTextUpsideDown:
horiz = 1.0 # qreal
vert = 1.0 # qreal
if self.objTextBackward:
horiz = -1.0
if self.objTextUpsideDown:
vert = -1.0
flippedPath = QPainterPath()
element = QPainterPath.Element
P2 = QPainterPath.Element
P3 = QPainterPath.Element
P4 = QPainterPath.Element
for i in range(0, textPath.elementCount()): # for(int i = 0; i < textPath.elementCount(); ++i)
element = textPath.elementAt(i)
if element.isMoveTo():
flippedPath.moveTo(horiz * element.x, vert * element.y)
elif element.isLineTo():
flippedPath.lineTo(horiz * element.x, vert * element.y)
elif element.isCurveTo():
# start point P1 is not needed
P2 = textPath.elementAt(i) # control point
P3 = textPath.elementAt(i + 1) # control point
P4 = textPath.elementAt(i + 2) # end point
flippedPath.cubicTo(horiz * P2.x, vert * P2.y,
horiz * P3.x, vert * P3.y,
horiz * P4.x, vert * P4.y)
objTextPath = flippedPath
else:
objTextPath = textPath
# Add the grip point to the shape path.
gripPath = objTextPath # QPainterPath
gripPath.connectPath(objTextPath)
gripPath.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
self.setObjectPath(gripPath)
示例2: DefaultCustomDelegate
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setPointSizeF [as 别名]
class DefaultCustomDelegate(QStyledItemDelegate):
'''Delegate to do custom draw of the items'''
memoized_size = {}
def __init__(self, parent):
'''Initialization'''
QStyledItemDelegate.__init__(self, parent)
self.bg_color = QColor('#000000')
self.bg_alternate_color = QColor('#333333')
self.new_bg_color = QColor('#0044dd')
self.new_bg_alternate_color = QColor('#223399')
self.user_color = QColor('#7AB4F5')
self.time_color = QColor('#7AB4F5')
self.replyto_color = QColor('#7AB4F5')
self.text_color = QColor('#FFFFFF')
self.separator_color = QColor('#000000')
self.fsize = 1.0
self.fm = None
self.minifm = None
self.normFont = None
self.miniFont = None
# print os.path.join(os.path.dirname(__file__),
# 'icons', 'reply.png')
self.reply_icon = QPixmap(os.path.join(os.path.dirname(__file__),
'icons', 'reply.png'))
# print dir(self.reply_icon)
self.retweet_icon = QPixmap(os.path.join(os.path.dirname(__file__),
'icons', 'retweet.png'))
self.geoloc_icon = QPixmap(os.path.join(os.path.dirname(__file__),
'icons', 'geoloc.png'))
def doZoomRefresh(self):
self.memoized_size.clear()
self.fm = None
self.minifm = None
self.normFont = None
self.miniFont = None
def sizeHint(self, option, index):
'''Custom size calculation of our items'''
uid = to_str(index.data(role=IDROLE)) + 'x' + str(option.rect.width()) #Fix Bug #967 (sometime uid have some strange unicode chars ... ?)
try:
return self.memoized_size[uid]
except:
tweet = to_str(index.data(Qt.DisplayRole))
# One time is enought sizeHint need to be fast
if not self.fm:
self.normFont = QFont(option.font)
self.normFont.setPointSizeF(option.font.pointSizeF()
* self.fsize)
self.fm = QFontMetrics(self.normFont)
if not self.minifm:
self.miniFont = QFont(option.font)
self.miniFont.setPointSizeF(option.font.pointSizeF()
* 0.8 * self.fsize)
self.minifm = QFontMetrics(self.miniFont)
height = self.fm.boundingRect(
0,
0,
option.rect.width() - 75,
800,
int(Qt.AlignTop) | int(Qt.AlignLeft) | int(Qt.TextWordWrap),
tweet,
).height()
reply_text = to_str(index.data(role=REPLYTEXTROLE))
if reply_text:
height += self.minifm.boundingRect(
0,
0,
option.rect.width() - 75,
800,
int(Qt.AlignTop) | int(Qt.AlignLeft)
| int(Qt.TextWordWrap),
reply_text,
).height() + 5
height += self.minifm.boundingRect(
0,
0,
option.rect.width() - 75,
800,
int(Qt.AlignTop) | int(Qt.AlignLeft) | int(Qt.TextWordWrap),
'LpqAT',
).height()
height += 10 # Spacer
if height < 70:
#.........这里部分代码省略.........