QTextFragment Class

QTextFragment 클래스는 단일 QTextCharFormat 으로 된 QTextDocument 에 텍스트 조각을 보관합니다. 더 보기...

헤더: #include <QTextFragment>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

참고: 이 클래스의 모든 함수는 재진입합니다.

공용 함수

QTextFragment()
QTextFragment(const QTextFragment &other)
QTextCharFormat charFormat() const
int charFormatIndex() const
bool contains(int position) const
QList<QGlyphRun> glyphRuns(int pos = -1, int len = -1) const
bool isValid() const
int length() const
int position() const
QString text() const
bool operator!=(const QTextFragment &other) const
bool operator<(const QTextFragment &other) const
QTextFragment &operator=(const QTextFragment &other)
bool operator==(const QTextFragment &other) const

상세 설명

텍스트 조각은 단일 문자 형식으로 저장된 텍스트 조각을 설명합니다. 문자 형식이 변경되는 텍스트는 서로 다른 형식의 텍스트 조각 시퀀스로 표현할 수 있습니다.

사용자가 조각의 텍스트를 편집하여 다른 문자 형식을 도입하면 형식이 변경되는 각 지점에서 조각의 텍스트가 분할되고 새 조각이 만들어집니다. 예를 들어 문장 중간에 일부 텍스트의 스타일을 변경하면 조각이 이전과 동일한 형식의 첫 번째와 세 번째 조각, 새 스타일을 적용한 두 번째 조각 등 세 개의 개별 조각으로 나뉩니다. 첫 번째 조각에는 문장 시작 부분의 텍스트가 포함되고, 두 번째 조각에는 중간 부분의 텍스트가 포함되며, 세 번째 조각에는 문장 끝 부분의 텍스트가 포함됩니다.

조각의 텍스트 및 문자 형식은 text() 및 charFormat() 함수를 사용하여 얻을 수 있습니다. length () 함수는 조각에 있는 텍스트의 길이를 제공합니다. position() 함수는 문서에서 조각이 시작되는 위치를 알려줍니다. 조각이 문서 내에서 특정 위치를 포함하는지 확인하려면 contains() 함수를 사용합니다.

QTextDocument서식 있는 텍스트 문서 구조를참조하세요 .

멤버 함수 문서

QTextFragment::QTextFragment()

새 빈 텍스트 조각을 만듭니다.

QTextFragment::QTextFragment(const QTextFragment &other)

other 텍스트 조각의 콘텐츠(텍스트 및 형식)를 이 텍스트 조각에 복사합니다.

QTextCharFormat QTextFragment::charFormat() const

텍스트 조각의 문자 형식을 반환합니다.

text()도 참조하세요 .

int QTextFragment::charFormatIndex() const

텍스트 조각의 문자 형식에 대한 문서의 내부 문자 형식 목록에 대한 인덱스를 반환합니다.

QTextDocument::allFormats()도 참조하세요 .

bool QTextFragment::contains(int position) const

텍스트 조각에 문서에서 지정된 position 의 텍스트가 포함되어 있으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

QList<QGlyphRun> QTextFragment::glyphRuns(int pos = -1, int len = -1) const

위치 pos 에서 시작하는 이 텍스트 조각의 len 문자에 해당하는 글리프를 반환합니다. 글리프의 위치는 QTextBlock 의 레이아웃 위치에 상대적입니다.

pos 이 0보다 작으면 QTextFragment 의 시작 부분이 기본값이 되고 len 이 0보다 작으면 조각의 길이가 기본값이 됩니다.

QGlyphRun, QTextBlock::layout(), QTextLayout::position() 및 QPainter::drawGlyphRun()도 참조하세요 .

bool QTextFragment::isValid() const

유효한 텍스트 조각인 경우(즉, 문서에서 유효한 위치가 있는 경우) true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

int QTextFragment::length() const

텍스트 조각의 문자 수를 반환합니다.

text()도 참조하세요 .

int QTextFragment::position() const

문서에서 이 텍스트 조각의 위치를 반환합니다.

QString QTextFragment::text() const

텍스트 조각을 일반 텍스트로 반환합니다.

length() 및 charFormat()도 참조하세요 .

bool QTextFragment::operator!=(const QTextFragment &other) const

이 텍스트 조각이 other 텍스트 조각과 다른 위치(다른 위치)에 있으면 true 을 반환하고, 그렇지 않으면 false를 반환합니다.

bool QTextFragment::operator<(const QTextFragment &other) const

이 텍스트 조각이 other 텍스트 조각보다 문서의 앞부분에 나타나면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

QTextFragment &QTextFragment::operator=(const QTextFragment &other)

other 텍스트 조각의 콘텐츠(텍스트 및 형식)를 이 텍스트 조각에 할당합니다.

bool QTextFragment::operator==(const QTextFragment &other) const

이 텍스트 조각이 other 텍스트 조각과 동일하면(같은 위치에 있으면) true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.