2

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

Caleb Huitt - cjhuitt
  • 14,785
  • 3
  • 42
  • 49
Aero Chocolate
  • 1,477
  • 6
  • 23
  • 39

3 Answers3

6
textEdit->verticalScrollBar()->setSliderPosition(
    textEdit->verticalScrollBar()->maximum());

Put that after the line where you insert text.

scotchi
  • 2,359
  • 2
  • 19
  • 21
  • Ahh, damn :( .ui/../form2.ui.h:37: error: ‘class QScrollBar’ has no member named ‘setSliderPosition’ .ui/../form2.ui.h:37: error: ‘class QScrollBar’ has no member named ‘maximum’ – Aero Chocolate Nov 29 '09 at 23:02
  • That was Qt 4; there's probably a Qt 3 equivalent. – scotchi Nov 30 '09 at 03:50
2

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.

Community
  • 1
  • 1
Juliano
  • 39,173
  • 13
  • 67
  • 73
  • It works for one time, but then it gets Fatal IO error: client killed. Not sure why that is happening. But I am refreshing my chat box every time someone sends a message to it. – Aero Chocolate Nov 29 '09 at 23:42
0

...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.

3DH
  • 1,461
  • 11
  • 11