Question

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, i.e. again inter-line spacing not included in result...

Is this incorrect usage from my side or something other ?

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top