简体   繁体   中英

QFontMetrics::leading() returns 0

Why next function returns 0 ? (My environment is: 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).

Calling to "fm.lineSpacing()" returns same result as "fm.height()".

Calling to "fm.boundingRect(QRect(), 0, "first line\\n second line\\n third line").height();" returns 16 * 3, ie again inter-line spacing not included in result...

Is this incorrect usage from my side or something other ?

According to the docs lineSpacing() is always equal to height() + leading()

height() is always equal to ascent()+descent()+1 (the 1 is for the base line).

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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