Windows 7 SP1
MSVS 2010
Qt 4.8.4
このコードを考えると:
#include <QTGui>
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()
<< text_block.blockFormat().lineHeightType();
}
コンソールには次のように表示されます。
"testing" 0 0
質問:lineHeightが「段落のLineHeightプロパティ」を返さないのはなぜですか?lineHeightTypeはシングルスペースに設定されています。
私は明らかにこれを理解していません。出力する前に行の高さを設定しようとしても、何も起こりません(lineHeight()はまだゼロです):
text_block.blockFormat().setLineHeight(30,QTextBlockFormat::SingleHeight);
明確にするために、私のアプリケーションでは、GUIウィンドウに出力するときに何も起こりません。
試しても:
qDebug() << text_block.text() << text_block.layout()->boundingRect().height();
私にゼロを与えます。