简体   繁体   English

QFontMetrics :: leading()返回0

[英]QFontMetrics::leading() returns 0

Why next function returns 0 ? 为什么下一个函数返回0? (My environment is: Windows Vista, vc++9, Qt4.5) (我的环境是:Windows Vista,vc ++ 9,Qt4.5)


int func()
{
    QPushButton button("Blah blah");
    QFontMetrics fm = button.fontMetrics();
    return fm.leading();
}

Calling to "fm.height()" returns reasonable results (16 px in my case). 调用“ fm.height()”会返回合理的结果(在我的情况下为16 px)。

Calling to "fm.lineSpacing()" returns same result as "fm.height()". 调用“ fm.lineSpacing()”将返回与“ fm.height()”相同的结果。

Calling to "fm.boundingRect(QRect(), 0, "first line\\n second line\\n third line").height();" 调用“ fm.boundingRect(QRect(),0,“第一行\\ n第二行\\ n第三行”).height();” returns 16 * 3, ie again inter-line spacing not included in result... 返回16 * 3,即结果中不包含行间距

Is this incorrect usage from my side or something other ? 这是我本人还是其他人的不正确用法?

According to the docs lineSpacing() is always equal to height() + leading() 根据文档, lineSpacing()始终等于height() + lineSpacing() leading()

height() is always equal to ascent()+descent()+1 (the 1 is for the base line). height()始终等于ascent()+descent()+1 (1代表基线)。

From here leading is "the space vertically between lines of text - name comes from the physical piece of lead that used to be used in mechanical printing process to separate lines of text" 这里开始,就是“文本行之间的垂直空间-名称来自用于机械打印过程中分隔文本行的物理引线”

So, what font are you using, and does it use a zero size leading? 那么,您使用的是哪种字体,并且它使用零大小的前导吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM