本文整理汇总了Python中PyQt5.Qt.QTextCursor.setCharFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.setCharFormat方法的具体用法?Python QTextCursor.setCharFormat怎么用?Python QTextCursor.setCharFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.setCharFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_lines
# 需要导入模块: from PyQt5.Qt import QTextCursor [as 别名]
# 或者: from PyQt5.Qt.QTextCursor import setCharFormat [as 别名]
def copy_lines(self, lo, hi, cursor):
''' Copy specified lines from the syntax highlighted buffer into the
destination cursor, preserving all formatting created by the syntax
highlighter. '''
num = hi - lo
if num > 0:
block = self.findBlockByNumber(lo)
while num > 0:
num -= 1
cursor.insertText(block.text())
dest_block = cursor.block()
c = QTextCursor(dest_block)
for af in block.layout().additionalFormats():
start = dest_block.position() + af.start
c.setPosition(start), c.setPosition(start + af.length, c.KeepAnchor)
c.setCharFormat(af.format)
cursor.insertBlock()
cursor.setCharFormat(NULL_FMT)
block = block.next()