QTextLine Class

QTextLine 클래스는 QTextLayout.. . 더 보기....

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

참고: 이 클래스의 모든 함수는 재인용됩니다.

공용 유형

enum CursorPosition { CursorBetweenCharacters, CursorOnCharacter }
enum Edge { Leading, Trailing }

공용 함수

QTextLine()
qreal ascent() const
qreal cursorToX(int *cursorPos, QTextLine::Edge edge = Leading) const
qreal cursorToX(int cursorPos, QTextLine::Edge edge = Leading) const
qreal descent() const
void draw(QPainter *painter, const QPointF &position) const
(since 6.5) QList<QGlyphRun> glyphRuns(int from, int length, QTextLayout::GlyphRunRetrievalFlags retrievalFlags) const
QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const
qreal height() const
qreal horizontalAdvance() const
bool isValid() const
qreal leading() const
bool leadingIncluded() const
int lineNumber() const
QRectF naturalTextRect() const
qreal naturalTextWidth() const
QPointF position() const
QRectF rect() const
void setLeadingIncluded(bool included)
void setLineWidth(qreal width)
void setNumColumns(int numColumns)
void setNumColumns(int numColumns, qreal alignmentWidth)
void setPosition(const QPointF &pos)
int textLength() const
int textStart() const
qreal width() const
qreal x() const
int xToCursor(qreal x, QTextLine::CursorPosition cpos = CursorBetweenCharacters) const
qreal y() const

상세 설명

텍스트 줄은 일반적으로 QTextLayout::createLine()에 의해 생성됩니다.

줄이 생성된 후에는 setLineWidth() 또는 setNumColumns() 함수를 사용하여 줄을 채울 수 있습니다. 선에는 선이 차지하는 사각형, rect(), 좌표, x() 및 y(), textLength(), width() 및 naturalTextWidth(), 텍스트에 대한 ascent() 및 descent() 등 여러 가지 속성이 있습니다. 줄을 기준으로 커서의 위치는 cursorToX(), 그 역은 xToCursor()에서 사용할 수 있습니다. 줄은 setPosition()로 이동할 수 있습니다.

회원 유형 문서

enum QTextLine::CursorPosition

상수
QTextLine::CursorBetweenCharacters0
QTextLine::CursorOnCharacter1

enum QTextLine::Edge

상수Value
QTextLine::Leading0
QTextLine::Trailing1

멤버 함수 문서

QTextLine::QTextLine()

유효하지 않은 줄을 만듭니다.

qreal QTextLine::ascent() const

선의 상승을 반환합니다.

descent() 및 height()도 참조하세요 .

qreal QTextLine::cursorToX(int *cursorPos, QTextLine::Edge edge = Leading) const

edge 을 고려하여 커서 위치 cursorPos 를 줄 안의 해당 x 위치로 변환합니다.

cursorPos 이 유효한 커서 위치가 아닌 경우 가장 가까운 유효한 커서 위치가 대신 사용되며 cursorPos 이 유효한 커서 위치를 가리키도록 수정됩니다.

xToCursor()도 참조하세요 .

qreal QTextLine::cursorToX(int cursorPos, QTextLine::Edge edge = Leading) const

과부하가 걸린 기능입니다.

qreal QTextLine::descent() const

선의 하강을 반환합니다.

ascent() 및 height()도 참조하세요 .

void QTextLine::draw(QPainter *painter, const QPointF &position) const

지정된 position 에 지정된 painter 에 선을 그립니다.

[since 6.5] QList<QGlyphRun> QTextLine::glyphRuns(int from, int length, QTextLayout::GlyphRunRetrievalFlags retrievalFlags) const

fromlength 에 정의된 범위의 문자에 대해 이 QTextLine 에 있는 모든 글리프에 대한 글리프 인덱스와 위치를 반환합니다. from 인덱스는 QTextLayout 을 포함하는 텍스트의 시작 부분을 기준으로 하며, 범위는 textStart() 및 textLength() 함수에 의해 지정된 QTextLine 범위 내에 있어야 합니다.

retrievalFlags 은 레이아웃에서 검색할 QGlyphRun 의 속성을 지정합니다. 할당과 메모리 소비를 최소화하려면 나중에 액세스해야 하는 속성만 포함하도록 설정해야 합니다.

from 가 음수이면 기본값은 textStart(), length 가 음수이면 기본값은 textLength()가 됩니다.

이 함수는 Qt 6.5에 도입되었습니다.

QTextLayout::glyphRuns()도 참조하세요 .

QList<QGlyphRun> QTextLine::glyphRuns(int from = -1, int length = -1) const

이 함수는 오버로드된 함수입니다.

fromlength 에 정의된 범위의 문자에 대해 이 QTextLine 의 모든 글리프에 대한 글리프 인덱스와 위치를 반환합니다. from 인덱스는 QTextLayout 을 포함하는 텍스트의 시작 부분을 기준으로 하며, 범위는 textStart() 및 textLength() 함수에 지정된 대로 QTextLine 범위 내에 있어야 합니다.

from 가 음수이면 textStart(), length 가 음수이면 textLength()의 반환값이 기본값이 됩니다.

참고: 이는 glyphRuns(from, length, QTextLayout::GlyphRunRetrievalFlag::GlyphIndexes | QTextLayout::GlyphRunRetrievalFlag::GlyphPositions)를 호출하는 것과 동일합니다.

QTextLayout::glyphRuns()도 참조하세요 .

qreal QTextLine::height() const

줄의 높이를 반환합니다. 선행이 포함되지 않은 경우 ascent() + descent()와 같습니다. 선행이 포함된 경우 ascent() + descent() + leading()와 같습니다.

ascent(), descent(), leading() 및 setLeadingIncluded()도 참조하세요 .

qreal QTextLine::horizontalAdvance() const

텍스트의 가로 전진을 반환합니다. 텍스트의 전진은 해당 위치에서 텍스트가 자연스럽게 그려질 다음 위치까지의 거리입니다.

텍스트 줄의 위치에 전진을 더하고 이를 두 번째 텍스트 줄의 위치로 사용하면 두 줄을 사이에 간격 없이 나란히 배치할 수 있습니다.

bool QTextLine::isValid() const

이 텍스트 줄이 유효하면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

qreal QTextLine::leading() const

줄의 선두를 반환합니다.

ascent(), descent() 및 height()도 참조하세요 .

bool QTextLine::leadingIncluded() const

양수 선행이 줄의 높이에 포함되면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

기본적으로 선행은 포함되지 않습니다.

setLeadingIncluded()도 참조하세요 .

int QTextLine::lineNumber() const

텍스트 엔진에서 줄의 위치를 반환합니다.

QRectF QTextLine::naturalTextRect() const

선으로 덮인 직사각형을 반환합니다.

qreal QTextLine::naturalTextWidth() const

텍스트가 차지하고 있는 줄의 너비를 반환합니다. 이 값은 항상 <=에서 width()까지이며 줄 바꿈 위치를 변경하지 않고 layout()에서 사용할 수 있는 최소 너비입니다.

QPointF QTextLine::position() const

텍스트 레이아웃의 위치에 상대적인 줄의 위치를 반환합니다.

setPosition()도 참조하세요 .

QRectF QTextLine::rect() const

선의 경계 직사각형을 반환합니다.

x(), y(), textLength() 및 width()도 참조하세요 .

void QTextLine::setLeadingIncluded(bool included)

included 이 참이면 줄의 높이에 양수 선행이 포함되고, 그렇지 않으면 선행이 포함되지 않습니다.

기본적으로 선행은 포함되지 않습니다.

음수 선행은 무시되므로 텍스트 줄을 사용하여 코드에서 줄을 겹치게 하여 처리해야 합니다.

leadingIncluded()도 참조하세요 .

void QTextLine::setLineWidth(qreal width)

주어진 width 으로 줄을 배치합니다. 줄은 시작 위치에서 줄에 들어갈 수 있는 만큼의 문자로 채워집니다. 줄 끝에서 텍스트를 분할할 수 없는 경우 다음 공백이나 텍스트 끝까지 추가 문자로 채워집니다.

void QTextLine::setNumColumns(int numColumns)

줄을 배치합니다. 줄은 시작 위치에서 numColumns 에 지정된 만큼의 문자로 채워집니다. numColumns 문자까지 텍스트를 분할할 수 없는 경우, 줄은 다음 공백 또는 텍스트 끝까지의 문자 수만큼 채워집니다.

void QTextLine::setNumColumns(int numColumns, qreal alignmentWidth)

줄을 배치합니다. 줄은 시작 위치에서 numColumns 에 지정된 만큼의 문자로 채워집니다. 텍스트가 numColumns 문자까지 분할될 수 없는 경우, 줄은 다음 공백 또는 텍스트 끝까지의 문자 수만큼 채워집니다. 제공된 alignmentWidth 은 정렬을 위한 기준 너비로 사용됩니다.

void QTextLine::setPosition(const QPointF &pos)

줄을 pos 위치로 이동합니다.

position()도 참조하세요 .

int QTextLine::textLength() const

줄에 있는 텍스트의 길이를 반환합니다.

naturalTextWidth()도 참조하세요 .

int QTextLine::textStart() const

QTextLayout 에 전달된 문자열의 시작 부분부터 줄의 시작 부분을 반환합니다.

qreal QTextLine::width() const

레이아웃() 함수에 지정된 대로 줄의 너비를 반환합니다.

naturalTextWidth(), x(), y(), textLength() 및 rect()도 참조하세요 .

qreal QTextLine::x() const

줄의 x 위치를 반환합니다.

rect(), y(), textLength() 및 width()도 참조하세요 .

int QTextLine::xToCursor(qreal x, QTextLine::CursorPosition cpos = CursorBetweenCharacters) const

커서 위치 유형에 따라 x 좌표 x 를 가장 가까운 일치하는 커서 위치( cpos)로 변환합니다. 결과 커서 위치에는 가능한 사전 편집 영역 텍스트가 포함됩니다.

cursorToX()도 참조하세요 .

qreal QTextLine::y() const

선의 y 위치를 반환합니다.

x(), rect(), textLength() 및 width()도 참조하세요 .

© 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.