PDA

View Full Version : QText Edit help please



munna
14th December 2006, 09:51
Hi,

Is there a way by which we can find the minimum height of a QTextEdit such that the vertical scrollbar will not appear ?

Alternately, is there a way to find the total number of lines of text available in QTextEdit?
Using this info and QFontMetrics we can probably find the ideal height.

Thanks a lot

rajesh
14th December 2006, 10:13
txtEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded );

OR


QSize size = txtEdit->minimumSize ();
int minHeight = size.height (http://www.qtcentre.org/forum/qsize.html#height) ();

if(txtEdit->height () == minHeight())
{
txtEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
}

wysota
14th December 2006, 10:20
QAbstractTextLayout::documentSize() should work. You can access the layout using QTextDocument::documentLayout().