QTextBlockFormat Class

QTextBlockFormat 클래스는 QTextDocument.. . 더보기...

헤더: #include <QTextBlockFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
상속합니다: QTextFormat

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

공용 유형

enum LineHeightTypes { SingleHeight, ProportionalHeight, FixedHeight, MinimumHeight, LineDistanceHeight }
enum class MarkerType { NoMarker, Unchecked, Checked }

공용 함수

QTextBlockFormat()
Qt::Alignment alignment() const
qreal bottomMargin() const
int headingLevel() const
int indent() const
bool isValid() const
qreal leftMargin() const
qreal lineHeight() const
qreal lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const
int lineHeightType() const
QTextBlockFormat::MarkerType marker() const
bool nonBreakableLines() const
QTextFormat::PageBreakFlags pageBreakPolicy() const
qreal rightMargin() const
void setAlignment(Qt::Alignment alignment)
void setBottomMargin(qreal margin)
void setHeadingLevel(int level)
void setIndent(int indentation)
void setLeftMargin(qreal margin)
void setLineHeight(qreal height, int heightType)
void setMarker(QTextBlockFormat::MarkerType marker)
void setNonBreakableLines(bool b)
void setPageBreakPolicy(QTextFormat::PageBreakFlags policy)
void setRightMargin(qreal margin)
void setTabPositions(const QList<QTextOption::Tab> &tabs)
void setTextIndent(qreal indent)
void setTopMargin(qreal margin)
QList<QTextOption::Tab> tabPositions() const
qreal textIndent() const
qreal topMargin() const

상세 설명

문서는 QTextBlock 객체로 표시되는 블록 목록으로 구성됩니다. 각 블록은 텍스트 단락, 표, 목록, 이미지 등 어떤 종류의 항목을 포함할 수 있습니다. 모든 블록에는 해당 블록의 특성을 지정하는 QTextBlockFormat이 연관되어 있습니다.

왼쪽에서 오른쪽 및 오른쪽에서 왼쪽 언어에 맞게 setLayoutDirection()로 블록의 방향을 설정할 수 있습니다. 단락 정렬은 setAlignment()로 설정합니다. 여백은 setTopMargin(), setBottomMargin(), setLeftMargin(), setRightMargin()로 제어합니다. 전체 들여쓰기는 setIndent(), 첫 줄의 들여쓰기는 setTextIndent()로 설정합니다.

줄 간격은 setLineHeight()로 설정하고 lineHeight() 및 lineHeightType()를 통해 검색합니다. 사용 가능한 줄 간격의 유형은 LineHeightTypes 열거형에 있습니다.

줄 바꿈은 setNonBreakableLines()로 활성화 및 비활성화할 수 있습니다.

단락의 배경을 칠하는 데 사용되는 브러시는 setBackground()로 설정되며, 텍스트 모양의 다른 측면은 setProperty() 함수와 OutlinePen, ForegroundBrush, BackgroundBrush QTextFormat::Property 값을 사용하여 사용자 지정할 수 있습니다.

텍스트 블록이 목록의 일부인 경우 listFormat() 함수로 액세스할 수 있는 목록 형식을 가질 수도 있습니다.

QTextBlockQTextCharFormat참조하세요 .

멤버 유형 문서

enum QTextBlockFormat::LineHeightTypes

이 열거형은 줄 간격 지원 단락이 가질 수 있는 다양한 유형을 설명합니다.

Constant설명
QTextBlockFormat::SingleHeight0기본 줄 높이: 단일 간격입니다.
QTextBlockFormat::ProportionalHeight1줄에 비례하는 간격(백분율)을 설정합니다. 예를 들어 이중 간격의 경우 200으로 설정합니다.
QTextBlockFormat::FixedHeight2줄 높이를 고정 줄 높이(픽셀 단위)로 설정합니다.
QTextBlockFormat::MinimumHeight3최소 줄 높이(픽셀 단위)를 설정합니다.
QTextBlockFormat::LineDistanceHeight4이렇게 하면 줄 사이에 지정된 높이(픽셀)가 추가됩니다.

lineHeight(), lineHeightType() 및 setLineHeight()도 참조하세요 .

enum class QTextBlockFormat::MarkerType

이 열거형은 목록 항목이 가질 수 있는 마커의 유형을 설명합니다. 목록 항목( QTextBlock::textList()이 목록을 반환하는 단락)에 마커가 있는 경우 일반 글머리 기호 대신 마커가 렌더링됩니다. 이러한 방식으로 확인 가능한 목록 항목은 같은 목록에서 일반 목록 항목과 혼합되어 전체 목록에 대해 QTextListFormat::style()에 지정된 글머리 기호 유형을 재정의할 수 있습니다.

상수설명
QTextBlockFormat::MarkerType::NoMarker0기본값으로 목록 항목의 글머리 기호가 표시됩니다.
QTextBlockFormat::MarkerType::Unchecked1목록 항목의 글머리 기호 대신 선택되지 않은 확인란이 표시됩니다.
QTextBlockFormat::MarkerType::Checked2목록 항목의 글머리 기호 대신 체크된 확인란이 표시됩니다.

향후 다른 유형의 단락 장식을 지정하도록 이 기능이 확장될 수 있습니다.

QTextListFormat::style()도 참조하세요 .

멤버 함수 문서

QTextBlockFormat::QTextBlockFormat()

새로운 QTextBlockFormat을 생성합니다.

Qt::Alignment QTextBlockFormat::alignment() const

단락의 정렬을 반환합니다.

setAlignment()도 참조하세요 .

qreal QTextBlockFormat::bottomMargin() const

단락의 아래쪽 여백을 반환합니다.

setBottomMargin() 및 topMargin()도 참조하세요 .

int QTextBlockFormat::headingLevel() const

단락이 제목인 경우 단락의 제목 수준을 반환하고, 제목이 아닌 경우 0을 반환합니다.

setHeadingLevel()도 참조하세요 .

int QTextBlockFormat::indent() const

단락의 들여쓰기를 반환합니다.

setIndent()도 참조하세요 .

bool QTextBlockFormat::isValid() const

이 블록 형식이 유효하면 true 을 반환하고, 그렇지 않으면 false를 반환합니다.

qreal QTextBlockFormat::leftMargin() const

단락의 왼쪽 여백을 반환합니다.

setLeftMargin(), rightMargin() 및 indent()도 참조하세요 .

qreal QTextBlockFormat::lineHeight() const

단락의 LineHeight 속성을 반환합니다.

LineHeightTypes, setLineHeight() 및 lineHeightType()도 참조하세요 .

qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const

scriptLineHeight 에 지정된 스크립트 줄의 높이와 지정된 scaling 계수를 기준으로 단락의 줄 높이를 반환합니다.

반환되는 값은 단락의 지정된 LineHeightType과 단락에 설정된 LineHeight 설정에 따라 달라집니다.

고정된 픽셀 수를 포함하는 높이의 경우 인쇄에 적합한 크기를 조정하기 위해 배율이 필요합니다.

LineHeightTypes, setLineHeight() 및 lineHeightType()도 참조하세요 .

int QTextBlockFormat::lineHeightType() const

이 함수는 단락의 LineHeightType 속성을 반환합니다.

LineHeightTypes, setLineHeight() 및 lineHeight()도 참조하세요 .

QTextBlockFormat::MarkerType QTextBlockFormat::marker() const

단락의 마커가 설정되어 있으면 해당 단락의 마커를 반환하고, 설정되어 있지 않으면 NoMarker 을 반환합니다.

setMarker()도 참조하세요 .

bool QTextBlockFormat::nonBreakableLines() const

단락의 줄이 끊어지지 않으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

setNonBreakableLines()도 참조하세요 .

QTextFormat::PageBreakFlags QTextBlockFormat::pageBreakPolicy() const

단락에 대해 현재 설정된 페이지 나누기 정책을 반환합니다. 기본값은 QTextFormat::PageBreak_Auto 입니다.

setPageBreakPolicy()도 참조하세요 .

qreal QTextBlockFormat::rightMargin() const

단락의 오른쪽 여백을 반환합니다.

setRightMargin() 및 leftMargin()도 참조하세요 .

void QTextBlockFormat::setAlignment(Qt::Alignment alignment)

단락의 alignment 을 설정합니다.

alignment()도 참조하세요 .

void QTextBlockFormat::setBottomMargin(qreal margin)

단락의 하단을 margin 으로 설정합니다.

bottomMargin(), setTopMargin(), setLeftMargin() 및 setRightMargin()도 참조하세요 .

void QTextBlockFormat::setHeadingLevel(int level)

단락의 제목을 설정합니다 level 여기서 1은 가장 높은 수준의 제목 유형(일반적으로 가능한 가장 큰 제목 글꼴 크기)이며, 값이 증가할수록 문서 안쪽으로 점점 더 깊어집니다(일반적으로 글꼴 크기가 작아짐). 예를 들어 HTML H1 태그를 읽을 때 제목 수준은 1로 설정됩니다. 제목 수준을 설정해도 글꼴 크기는 자동으로 변경되지 않지만 QTextDocumentFragment::fromHtml()는 제목 수준과 글꼴 크기를 동시에 설정합니다.

단락이 제목이 아닌 경우 수준은 0(기본값)으로 설정해야 합니다.

headingLevel()도 참조하세요 .

void QTextBlockFormat::setIndent(int indentation)

단락의 indentation 를 설정합니다. 여백은 setLeftMargin() 및 setTextIndent()를 사용하여 들여쓰기와 독립적으로 설정합니다. indentation 은 문서 전체의 표준 들여쓰기에 곱해지는 정수로, 단락의 실제 들여쓰기가 됩니다.

indent() 및 QTextDocument::indentWidth()도 참조하세요 .

void QTextBlockFormat::setLeftMargin(qreal margin)

단락의 왼쪽을 설정합니다 margin. 들여쓰기는 setIndent()를 사용하여 별도로 적용할 수 있습니다.

leftMargin(), setRightMargin(), setTopMargin() 및 setBottomMargin()도 참조하세요 .

void QTextBlockFormat::setLineHeight(qreal height, int heightType)

단락의 줄 높이를 LineHeightTypes 열거형에 설명된 방식으로 heightType 에 종속되는 height 에 지정된 값으로 설정합니다.

LineHeightTypes, lineHeight() 및 lineHeightType()도 참조하세요 .

void QTextBlockFormat::setMarker(QTextBlockFormat::MarkerType marker)

단락과 함께 렌더링할 장식 유형을 marker 으로 설정합니다. 예를 들어 목록 항목은 글머리 기호 대신 체크박스를 선택하거나 선택하지 않은 상태로 장식할 수 있습니다. 기본값은 NoMarker 입니다.

marker()도 참조하세요 .

void QTextBlockFormat::setNonBreakableLines(bool b)

b 이 참이면 단락의 줄은 끊을 수 없는 것으로 처리되고, 그렇지 않으면 끊을 수 있는 것으로 처리됩니다.

nonBreakableLines()도 참조하세요 .

void QTextBlockFormat::setPageBreakPolicy(QTextFormat::PageBreakFlags policy)

단락의 페이지 나누기 정책을 policy 로 설정합니다.

pageBreakPolicy()도 참조하세요 .

void QTextBlockFormat::setRightMargin(qreal margin)

단락의 오른쪽을 설정합니다 margin.

rightMargin(), setLeftMargin(), setTopMargin() 및 setBottomMargin()도 참조하세요 .

void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs)

텍스트 블록의 탭 위치를 tabs 에 지정된 위치로 설정합니다.

tabPositions()도 참조하세요 .

void QTextBlockFormat::setTextIndent(qreal indent)

블록의 첫 줄에 indent 을 설정합니다. 이렇게 하면 단락의 첫 줄을 다른 줄과 다르게 들여쓰기하여 텍스트의 가독성을 높일 수 있습니다.

textIndent(), setLeftMargin(), setRightMargin(), setTopMargin() 및 setBottomMargin()도 참조하세요 .

void QTextBlockFormat::setTopMargin(qreal margin)

단락의 상단을 margin 으로 설정합니다.

topMargin(), setBottomMargin(), setLeftMargin() 및 setRightMargin()도 참조하세요 .

QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const

텍스트 블록에 대해 정의된 탭 위치 목록을 반환합니다.

setTabPositions()도 참조하세요 .

qreal QTextBlockFormat::textIndent() const

단락의 텍스트 들여쓰기를 반환합니다.

setTextIndent()도 참조하세요 .

qreal QTextBlockFormat::topMargin() const

단락의 상단 여백을 반환합니다.

setTopMargin() 및 bottomMargin()도 참조하세요 .

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