[Qt-interest] Autoscrolling--yet friendly--QTextEdit

william.crocker at analog.com william.crocker at analog.com
Fri Dec 10 12:52:30 CET 2010


> 
> I would like a QTextEdit instance to behave as follows. As long as the user has 
> not touched the scroll wheel to read what has scrolled out of the widget, 
> QTextEdit would auto-scroll to show the last line, but QTextEdit would not 
> wrestle against the user by insisting to move the cursor to the bottom even 
> while the user is trying to read something that scrolled out of the screen.
>  
> Here is my attempt at a solution. As long as the guard “user_has_scrolled” is 
> not true, MyQTextEdit scrolls to QTextCursor::End. Once the guard is true, 
> auto-scroll is disabled.
>  

I have implemented this in the past with:

     1 - Append new text.
     2 - If end was visible before the addition,
         auto-scroll to the new end.



More information about the Qt-interest-old mailing list