本文整理汇总了Python中PyQt5.QtGui.QTextCursor.hasSelection方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.hasSelection方法的具体用法?Python QTextCursor.hasSelection怎么用?Python QTextCursor.hasSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.hasSelection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getCursorSelectAll
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import hasSelection [as 别名]
def _getCursorSelectAll(self, morph):
'''
Cursor on entire document (text) of a morph (DocumentElement) of type Text.
morph may be empty of text.
!!! Cursor may not hasSelection() if morph is empty of text.
'''
cursor = QTextCursor(morph.document())
cursor.setPosition(0)
cursor.clearSelection()
# programmatic selection requires movePosition(), not setPosition()
cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor)
# In Qt, cursor is valid for further operations regardless of whether hasSelection()
# ensure document not empty => cursor.hasSelection
assert morph.document().isEmpty() or cursor.hasSelection()
return cursor
示例2: get_find_range
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import hasSelection [as 别名]
def get_find_range(self):
tc = QTextCursor(self.range_sel.cursor) # copy of range cursor
if not tc.hasSelection() :
tc.select(QTextCursor.Document)
return tc