1
QTextEdit
에 여러 글꼴이있는 텍스트가 표시되어 있습니다. 글꼴 정보로 각 문자 (또는 텍스트 블록)를 가져 오려고합니다. QTextDocument
에 대해 QTextBlock
을 시도했습니다. 하지만 그것은 ontype 글꼴을 가진 문자열 인 것 같습니다.QTextEdit의 글꼴을 가져 오는 방법
QTextEdit
의 글꼴을 가져 오는 방법이 있습니까?
QTextEdit
에 여러 글꼴이있는 텍스트가 표시되어 있습니다. 글꼴 정보로 각 문자 (또는 텍스트 블록)를 가져 오려고합니다. QTextDocument
에 대해 QTextBlock
을 시도했습니다. 하지만 그것은 ontype 글꼴을 가진 문자열 인 것 같습니다.QTextEdit의 글꼴을 가져 오는 방법
QTextEdit
의 글꼴을 가져 오는 방법이 있습니까?
당신은 QTextDocument
에서이 정보를 얻을 수 있어야합니다 :
QTextDocument doc;
QTextBlock currentBlock = doc.firstBlock();
while (currentBlock.isValid()) {
QTextBlockFormat blockFormat = currentBlock.blockFormat();
QTextCharFormat charFormat = currentBlock.charFormat();
QFont font = charFormat.font();
// each QTextBlock holds multiple fragments of text, so iterate over it:
QTextBlock::iterator it;
for (it = currentBlock.begin(); !(it.atEnd()); ++it) {
QTextFragment currentFragment = it.fragment();
if (currentFragment.isValid()) {
// a text fragment also has a char format with font:
QTextCharFormat fragmentCharFormat = currentFragment.charFormat();
QFont fragmentFont = fragmentCharFormat.font();
// etc...
}
}
currentBlock = currentBlock.next();
}
의미가 있습니다. 도와 줘서 고마워! –