고급 서식 있는 텍스트 처리
대용량 파일 처리하기
Qt는 텍스트 처리에 사용되는 파일의 크기를 제한하지 않습니다. 대부분의 경우 이는 문제가 되지 않습니다. 그러나 특히 큰 파일의 경우 응용 프로그램이 응답하지 않거나 메모리가 부족할 수 있습니다. 로드할 수 있는 파일의 크기는 하드웨어와 Qt 및 자체 애플리케이션의 구현에 따라 다릅니다.
이 문제가 발생하면 다음 문제를 해결하는 것이 좋습니다:
- Qt는 작은 단락을 더 잘 처리하므로 큰 단락을 작은 단락으로 나누는 것을 고려해야 합니다. 또한 일정한 간격으로 줄 바꿈을 삽입할 수도 있는데, 이는 QTextEdit 에서 하나의 큰 단락과 동일하게 보일 것입니다.
- maximumBlockCount()을 사용하여 QTextDocument 에서 블록의 양을 줄일 수 있습니다. QTextEdit 의 경우 블록 수만큼만 문서가 커집니다.
- 텍스트 편집에 텍스트를 추가할 때는 편집 블록에 추가하는 것이 유리합니다(아래 예 참조). 그 결과 텍스트 편집에서 전체 문서 구조를 한 번에 만들 필요가 없습니다.
목록에서 후자의 기법을 예로 들어 보겠습니다. 텍스트 편집이 표시된다고 가정합니다.
textEdit.show(); textCursor.beginEditBlock(); for (int i = 0; i < 1000; ++i) { textCursor.insertBlock(); textCursor.insertText(paragraphText.at(i)); } textCursor.endEditBlock();
© 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.