QTextBoundaryFinderclass provides a way of finding Unicode text boundaries in a string. 更多 …
def
boundaryReasons
()
def
isAtBoundary
()
def
isValid
()
def
position
()
def
setPosition
(position)
def
string
()
def
toEnd
()
def
toNextBoundary
()
def
toPreviousBoundary
()
def
toStart
()
def
type
()
QTextBoundaryFinderallows to find Unicode text boundaries in a string, accordingly to the Unicode text boundary specification (see Unicode Standard Annex #14 and Unicode Standard Annex #29 ).
QTextBoundaryFindercan operate on aQStringin four possible modes depending on the value ofBoundaryType.Units of Unicode characters that make up what the user thinks of as a character or basic unit of the language are here called Grapheme clusters. The two unicode characters ‘A’ + diaeresis do for example form one grapheme cluster as the user thinks of them as one character, yet it is in this case represented by two unicode code points (see http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries ).
Word boundaries are there to locate the start and end of what a language considers to be a word (see http://www.unicode.org/reports/tr29/#Word_Boundaries ).
Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences (see http://www.unicode.org/reports/tr29/#Sentence_Boundaries and http://www.unicode.org/reports/tr14/ ).
The first position in a string is always a valid boundary and refers to the position before the first character. The last position at the length of the string is also valid and refers to the position after the last character.
QTextBoundaryFinder
¶
QTextBoundaryFinder(type, string)
QTextBoundaryFinder(other)
- param type
BoundaryType- param string
unicode
- param other
Constructs an invalid
QTextBoundaryFinder
对象。
创建
QTextBoundaryFinder
object of
type
operating on
string
.
拷贝
QTextBoundaryFinder
对象,
other
.
PySide2.QtCore.QTextBoundaryFinder.
BoundaryType
¶
|
常量 |
描述 |
|---|---|
|
QTextBoundaryFinder.Grapheme |
Finds a grapheme which is the smallest boundary. It including letters, punctuation marks, numerals and more. |
|
QTextBoundaryFinder.Word |
Finds a word. |
|
QTextBoundaryFinder.Line |
Finds possible positions for breaking the text into multiple lines. |
|
QTextBoundaryFinder.Sentence |
Finds sentence boundaries. These include periods, question marks etc. |
PySide2.QtCore.QTextBoundaryFinder.
BoundaryReason
¶
|
常量 |
描述 |
|---|---|
|
QTextBoundaryFinder.NotAtBoundary |
The boundary finder is not at a boundary position. |
|
QTextBoundaryFinder.BreakOpportunity |
The boundary finder is at a break opportunity position. Such a break opportunity might also be an item boundary (either , , or combination of both), a mandatory line break, or a soft hyphen. |
|
QTextBoundaryFinder.StartOfItem |
Since 5.0. The boundary finder is at the start of a grapheme, a word, a sentence, or a line. |
|
QTextBoundaryFinder.EndOfItem |
Since 5.0. The boundary finder is at the end of a grapheme, a word, a sentence, or a line. |
|
QTextBoundaryFinder.MandatoryBreak |
Since 5.0. The boundary finder is at the end of line (can occur for a Line boundary type only). |
|
QTextBoundaryFinder.SoftHyphen |
The boundary finder is at the soft hyphen (can occur for a Line boundary type only). |
PySide2.QtCore.QTextBoundaryFinder.
boundaryReasons
(
)
¶
BoundaryReasons
Returns the reasons for the boundary finder to have chosen the current position as a boundary.
PySide2.QtCore.QTextBoundaryFinder.
isAtBoundary
(
)
¶
bool
返回
true
if the object’s
position()
is currently at a valid text boundary.
PySide2.QtCore.QTextBoundaryFinder.
isValid
(
)
¶
bool
返回
true
if the text boundary finder is valid; otherwise returns
false
. A default
QTextBoundaryFinder
is invalid.
PySide2.QtCore.QTextBoundaryFinder.
position
(
)
¶
int
Returns the current position of the
QTextBoundaryFinder
.
The range is from 0 (the beginning of the string) to the length of the string inclusive.
另请参阅
PySide2.QtCore.QTextBoundaryFinder.
setPosition
(
position
)
¶
position
–
int
Sets the current position of the
QTextBoundaryFinder
to
position
.
若
position
is out of bounds, it will be bound to only valid positions. In this case, valid positions are from 0 to the length of the string inclusive.
另请参阅
PySide2.QtCore.QTextBoundaryFinder.
string
(
)
¶
unicode
Returns the string the
QTextBoundaryFinder
object operates on.
PySide2.QtCore.QTextBoundaryFinder.
toEnd
(
)
¶
Moves the finder to the end of the string. This is equivalent to
setPosition
(string.
length()
).
另请参阅
PySide2.QtCore.QTextBoundaryFinder.
toNextBoundary
(
)
¶
int
Moves the
QTextBoundaryFinder
to the next boundary position and returns that position.
Returns -1 if there is no next boundary.
PySide2.QtCore.QTextBoundaryFinder.
toPreviousBoundary
(
)
¶
int
Moves the
QTextBoundaryFinder
to the previous boundary position and returns that position.
Returns -1 if there is no previous boundary.
PySide2.QtCore.QTextBoundaryFinder.
toStart
(
)
¶
Moves the finder to the start of the string. This is equivalent to
setPosition
(0).
另请参阅
PySide2.QtCore.QTextBoundaryFinder.
type
(
)
¶
Returns the type of the
QTextBoundaryFinder
.