이 페이지에서

QTextList Class

QTextList 클래스는 QTextDocument 에서 항목들이 꾸며진 목록을 제공합니다. 더 보기...

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

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

공개 함수

void add(const QTextBlock &block)
int count() const
QTextListFormat format() const
QTextBlock item(int i) const
int itemNumber(const QTextBlock &block) const
QString itemText(const QTextBlock &block) const
void remove(const QTextBlock &block)
void removeItem(int i)
void setFormat(const QTextListFormat &format)

상세 설명

목록은 일련의 텍스트 블록으로 구성되며, 각 블록은 글머리 기호나 기타 기호로 표시됩니다. 여러 단계의 목록을 사용할 수 있으며, 자동 번호 매기기 기능을 통해 순서대로 번호가 매겨진 숫자 및 알파벳 목록을 지원합니다.

목록은 텍스트 커서를 사용하여 현재 위치에 빈 목록을 삽입하거나, 기존 텍스트를 새 목록으로 이동하여 생성할 수 있습니다. QTextCursor::insertList() 함수는 커서 위치에 빈 블록을 문서에 삽입하고, 이를 목록의 첫 번째 항목으로 만듭니다.

    QTextListFormat listFormat;
    if (list) {
        listFormat = list->format();
        listFormat.setIndent(listFormat.indent() + 1);
    }

    listFormat.setStyle(QTextListFormat::ListDisc);
    cursor.insertList(listFormat);

QTextCursor::createList() 함수는 커서가 위치한 블록의 내용을 가져와 이를 새 목록의 첫 번째 항목으로 만듭니다.

커서의 현재 목록은 QTextCursor::currentList()을 통해 확인할 수 있습니다.

목록에 포함된 항목의 수는 ` count()` 함수를 통해 확인할 수 있습니다. 각 항목은 ` item()` 함수를 사용하여 목록 내 인덱스로 가져올 수 있습니다. 마찬가지로, 특정 항목의 인덱스는 ` itemNumber()` 함수를 사용하여 찾을 수 있습니다. 각 항목의 텍스트는 ` itemText()` 함수를 사용하여 확인할 수 있습니다.

목록에 포함된 항목들이 문서 내에서 인접한 요소가 아닐 수 있다는 점에 유의하십시오. 예를 들어, 다단계 목록의 최상위 항목들은 목록의 하위 단계에 있는 항목들에 의해 분리되어 있을 수 있습니다.

removeItem() 함수를 사용하여 인덱스를 통해 목록 항목을 삭제할 수 있습니다. remove()는 목록에서 지정된 항목을 삭제합니다.

목록의 형식은 setFormat() 함수로 설정하고, format() 함수로 읽습니다. 이 형식은 개별 항목이 아닌 목록 자체의 꾸밈을 설명합니다.

QTextBlock, QTextListFormat 및 QTextCursor도 참조하십시오 .

멤버 함수 문서

void QTextList::add(const QTextBlock &block)

지정된 block 을 목록에 포함시킵니다.

remove() 및 removeItem()도 참조하십시오 .

int QTextList::count() const

목록에 포함된 항목의 개수를 반환합니다.

QTextListFormat QTextList::format() const

목록의 형식을 반환합니다.

setFormat()도 참조하십시오 .

QTextBlock QTextList::item(int i) const

목록에서 i 번째 텍스트 블록을 반환합니다.

count() 및 itemText()도 참조하십시오 .

int QTextList::itemNumber(const QTextBlock &block) const

주어진 ` block`에 해당하는 목록 항목의 인덱스를 반환합니다. 해당 블록이 목록에 없는 경우 -1을 반환합니다.

QString QTextList::itemText(const QTextBlock &block) const

지정된 ` block`에 해당하는 목록 항목의 텍스트를 반환합니다.

void QTextList::remove(const QTextBlock &block)

지정된 block 를 목록에서 제거합니다.

add() 및 removeItem()도 참조하십시오 .

void QTextList::removeItem(int i)

목록에서 항목 위치 i 에 있는 항목을 제거합니다. 목록의 마지막 항목이 제거되면, 해당 목록을 소유하고 있는 QTextDocument 에 의해 목록이 자동으로 삭제됩니다.

add() 및 remove()도 참조하십시오 .

void QTextList::setFormat(const QTextListFormat &format)

목록의 서식을 format 로 설정합니다.

format()도 참조하십시오 .

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