user1542137
user1542137

Reputation: 11

How to determine the font of a QTextBlock

Let's say a user pastes some random text into a QTextEdit. How do you determine which font that text is in. For example, Chinese.

I've tried getting the QTextCharFormat for the block. But it seems to be empty of information. Querying for fontFamily() gets me an empty string.

I've also tried to use the QTextLayout - but that seems to get me the default layout for the document, not for the specific text block.

Thanks for any pointers.

Upvotes: 0

Views: 148

Answers (1)

user1542137
user1542137

Reputation: 11

It seems you have to go to iterate over the QTextFragment's inside your block. The fragments are what contain the specific font information.

Upvotes: 1

Related Questions