Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to get the line height of a QTextBlock?
Therefore last edited by
Windows 7 SP1
Given this code:
int main(int argc, char argv)
QTextDocument text_document = new QTextDocument("testing");
QTextBlock text_block = text_document->begin();
qDebug() << text_block.text() << text_block.blockFormat().lineHeight()
The console displays:
@"testing" 0 0@
Question: Why doesn't lineHeight return "the LineHeight property for the paragraph"? The lineHeightType is set for single spacing.
I am clearly not understanding this. When I try to set the line height before outputting, nothing happens (lineHeight() is still zero):
To be clear, in my application nothing happens when outputting to a GUI window.
@qDebug() << text_block.text() << text_block.layout()->boundingRect().height();@