Results 1 to 3 of 3

Thread: Scrolling QTextEdit

  1. #1
    Join Date
    Jun 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Scrolling QTextEdit

    I am trying to use Qt's QTextEdit widget to display status messages as my application progresses. As the display fills up, a vertical scroll bar is displayed. What I would also like to happen is for the display to automatically scroll so that the new text is displayed. How do I do that?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Scrolling QTextEdit

    I suggest you use QPlainTextEdit instead of QTextEdit, it has better performance when no advanced editing capabilities are required.

    As for scrolling you can either use:
    Qt Code:
    1. QScrollBar *vs = verticalScrollBar();
    2. vs->setValue(vs->maximum());
    To copy to clipboard, switch view to plain text mode 

    or use QPlainTextEdit::ensureCursorVisible() with QTextCursor::movePosition()
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    superteny (9th June 2009)

  4. #3
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling QTextEdit

    Also consider using QTextBrowser, a subclass of QTextEdit, if the user shoudn't be able to edit the text.

    I prefer to use a view class to display messahes, such as QListView or QTableView.

Similar Threads

  1. Drawing on QTextEdit
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2009, 09:40
  2. auto scrolling QTextEdit
    By msmihai in forum Newbie
    Replies: 1
    Last Post: 8th January 2009, 19:08
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  4. Scrolling in QTextEdit Widget
    By ajb_advance in forum Newbie
    Replies: 2
    Last Post: 25th September 2007, 11:34
  5. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.