Qt, how to set text edit scroll bar to the bottom? C++

9.5k views Asked by At

I have the text edit box as a chat window, but I was wondering if there was a way to set the scroll bar to be at the bottom to show the most updated message.

I am currently using Qt3 and C++.

chat_box->.... I tried looking and was only able to find "ScrollBarMode" but it only lets me turn it on or off or auto... which doesn't really help.

Thanks for the help :D

3

There are 3 answers

1
Juliano On BEST ANSWER

scotchi's answer would be correct if it was Qt4. Qt3 solution would be something like:

QScrollBar *v = chat_box->verticalScrollBar();
v->setValue(v->maxValue());

I didn't test this code since I don't have Qt3 anymore. Check if it works.

0
3DH On

...if possible (I don't know your environment) please switch to Qt4 - there are so many disadvantages and missing supprt, missing functionality etc. in Qt3.

ciao, Chris

PS: It's fairly easy to switch to Qt4 - you don't have to rewrite all of your code, because Qt4 has build in Qt3-Support with a converter tool for your sources.

2
scotchi On
textEdit->verticalScrollBar()->setSliderPosition(
    textEdit->verticalScrollBar()->maximum());

Put that after the line where you insert text.