[Qt-interest] How to scroll QTextEdit to the end

Nikos Chantziaras realnc at arcor.de
Mon Jun 21 00:53:59 CEST 2010


On 06/21/2010 01:21 AM, yogesh upreti wrote:
> Hallo Group,
> I have a QTextEdit Widget in my gui, which I use to display the log of
> work being performed by my programme.
> How do I make it sure that in this text edit (which is read only),
> whenever I insert a text, it should scroll to the bottom.
> I use this code in textChanged() signal of MyTextEdit. But this somehow
> doesn't work.
>
> QScrollBar *hbar = ui->MyTextEdit->horizontalScrollBar();
> hbar->setValue(hbar->maximum());
>
> Is this piece of code correct???

Try QAbstractSlider::triggerAction(QAbstractSlider::SliderToMaximum).



More information about the Qt-interest-old mailing list