Results 1 to 2 of 2

Thread: Limit Amount of Text in a QTextEdit

  1. #1
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Limit Amount of Text in a QTextEdit

    I need to limit the amount of text in a QTextEdit so that the user can't go beyond the size of visible space, that is, no scrolling. If the user tries to do so, i need to emit a signal to post a limit message.

    Stopping scrolling leads to a very poor document response, both for the last line and the cursor. Limiting the number of blocks can not overcome long lines. Is there a good way to do this? Thanks.

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Limit Amount of Text in a QTextEdit

    Take a look at
    QRect QPainter::boundingRect ( const QRect & rectangle, int flags, const QString & text )

    With that function you can check at every keyboard input of it will exceed your preferred size.

Similar Threads

  1. QTextEdit - how to limit maximum length?
    By Henrikas[MI] in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2010, 20:38
  2. How to read only a certain amount of bytes
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2009, 07:38
  3. amount of items in QTreeWidget
    By supergillis in forum Qt Programming
    Replies: 4
    Last Post: 1st August 2008, 22:38
  4. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 16:45
  5. Setting Max Limit in Text Box
    By kenny_isles in forum Newbie
    Replies: 4
    Last Post: 15th August 2007, 08:40

Tags for this Thread

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.