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()도 참조하세요 .

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