Results 1 to 4 of 4

Thread: QTextEdit fixed size with no scroll

  1. #1
    Join Date
    Aug 2012
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QTextEdit fixed size with no scroll

    Is there anyway to completely disable the vertical scrolling of a QTextEdit? What I'm trying to do is have a wysiwyg editor to make labels and I need a fixed size text area that will stop accepting input when there is no room left. We are implementing auto sizing of the text and when the minimum text size is met and the user is out of space we want to stop accepting input. I can't seem to find a way to do this, you can disable scrollbars but the widget keeps scrolling. When I try to do the autosizing using the size of the rect it reports back the wrong size, what I really want is the viewable size of the rect.

  2. #2
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit fixed size with no scroll

    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  3. #3
    Join Date
    Aug 2012
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QTextEdit fixed size with no scroll

    well, that doesn't actually fix the size of the widget it just hides the scrollbars, so not much help. I have tried experimenting with QGraphicsTextItem and think I might be able to get that working by setting the QGraphicsScene rect to a fixed size QRect. Thanks anyways for your response.

  4. #4
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit fixed size with no scroll

    maybe you should look at QTextDocument :

    Qt Code:
    1. void YourTextEdit::keyPressEvent(QKeyEvent *event)
    2. {
    3. if(document()->characterCount() > DEFINED_MAX_CHAR) return;
    4. QTextEdit::keyPressEvent(event);
    5. }
    To copy to clipboard, switch view to plain text mode 

    (not tested)

    QTextDocument also has a size() method ...
    Last edited by thomas@itest; 8th August 2012 at 12:21. Reason: QSizeF QtextDocument::size () const

Similar Threads

  1. Replies: 0
    Last Post: 14th February 2012, 15:43
  2. Replies: 4
    Last Post: 20th November 2009, 12:25
  3. Fixed size axes
    By wim12 in forum Qwt
    Replies: 4
    Last Post: 15th May 2009, 12:37
  4. Replies: 3
    Last Post: 5th February 2009, 15:32
  5. QDockWidget fixed size?
    By Michiel in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2006, 02:48

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
  •  
Qt is a trademark of The Qt Company.