PDA

View Full Version : space between lines in QTextEdit



Lele
18th September 2006, 21:15
Hi,
is there a way to control the space between lines in a QTextEdit Control?
or some trick for having a larger space using fonts?
Thanks in advance
Bye

high_flyer
19th September 2006, 11:38
The only thing I found in the docs is:

qreal QTextLine::height () const

Returns the line's height. This is equal to ascent() + descent() + 1.

See also ascent() and descent().

But I don't know how you can influence ascent() and descent(), maybe it is a resulting thing from the text layout object params.

Oh wait a minute, you don't want to change the line hight, but the space between the lines rihgt?
The look here:
http://doc.trolltech.com/4.1/qtextlayout.html

Here's some pseudo code that presents the layout phase:

int leading = fontMetrics.leading();
int height = 0;
qreal widthUsed = 0;
textLayout.beginLayout();
while (1) {
QTextLine line = textLayout.createLine();
if (!line.isValid())
break;

line.setLineWidth(lineWidth);
height += leading;
line.setPosition(QPoint(0, height));
height += line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
}
textLayout.endLayout();

Lele
19th September 2006, 14:05
Thanks for the suggestion,
I'm trying to figure it out how to use it in a QtextEdit
thanks again
bye