tags:

views:

81

answers:

1

Hello guys,

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 ?

+1  A: 

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?

Glen
I'm using predefined font (default font for buttons on Vista system) for buttons' captions (buttons' text in Qt terminology). When I set multiline text to button, each line of text separated from neighboring lines with some space (non zero space). So, I can't understand, why leading() returns "0", but indeed I have some spacing between lines (which I can't calculate thought leading() call)...
vnm