PDA

View Full Version : how to detect when QTextEdit's content is too large to fit



giotto
17th January 2008, 00:18
I wan't to detect to when the content is to large.
For example: if my QTextEdit can show 4 lines of text, but it has 5 lines now.

There should be a way, 'cause if Qt::ScrollBarAsNeeded is set, then when I reach the fifth line, QTextEdit has a Scrollbar. I tried to find the signal which is detected when Qt::ScrollBarAsNeeded is on, but I did'n find anything.

Do you have any idea?

giotto

The Storm
17th January 2008, 00:40
Perhaps you can use the signal textChanged() and in it to chek if QTextEdit::horizontalScrollBar() will return a valid pointer, if not then there is still no a scrollbar so the text is not too large. :)

giotto
17th January 2008, 00:52
Perhaps you can use the signal textChanged() and in it to chek if QTextEdit::horizontalScrollBar() will return a valid pointer, if not then there is still no a scrollbar so the text is not too large. :)

Is there a way to check that the ponter is valid?
Hmmmm, does this if I set Qt::ScrollBarAlwaysOff?

The Storm
17th January 2008, 01:34
Dunno for the flags but the pointer you can check very easy


if (horizontalScrollBar()) // The ponter is valid
// some code...
else // The pointer is not valid
// some other code...

giotto
17th January 2008, 09:40
Dunno for the flags but the pointer you can check very easy


if (horizontalScrollBar()) // The ponter is valid
// some code...
else // The pointer is not valid
// some other code...


this if is always true....

wysota
17th January 2008, 11:13
Because the bar is always there, it's just hidden. Check its value range instead or check if the bar isVisible().

giotto
18th January 2008, 00:46
this is working solution:)



connect(editor->verticalScrollBar(),SIGNAL(rangeChanged(int,int)), this,SLOT(echoNewRange(int,int)));