Results 1 to 4 of 4

Thread: multiple textedits inside layouts and scrollarea

  1. #1
    Join Date
    Jan 2008
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default multiple textedits inside layouts and scrollarea

    Hi,

    not sure if this is trivial, but I cannot seem to find the solution for this one... so maybe a kind soul can steer me towards the solution?

    I'm trying to have two QTextEdit widgets managed by a QVBoxLayout inside a QScrollArea in such a way that: QTextEdits never (need to) show their scrollbars but that instead the scroll area grows. The QTextEdits also should only use the minimum amount of vertical space.

    Whatever I do, the QTextEdits will always eventually show scrollbars...

    Do I have to write my own layout manager?

    Cheers,

    Andres

  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: multiple textedits inside layouts and scrollarea

    Reimplement sizeHint() from QTextEdit to take into consideration QTextDocument::size of the document it is showing and set the size policy of the text edit widget to minimumExpanding or similar.

    Here is a sample implementation (you might just copy it): http://doc.qt.nokia.com/qt-maemo-4.6...resizer-h.html
    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. #3
    Join Date
    Jan 2008
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: multiple textedits inside layouts and scrollarea

    Quote Originally Posted by wysota View Post
    Reimplement sizeHint() from QTextEdit to take into consideration QTextDocument::size of the document it is showing and set the size policy of the text edit widget to minimumExpanding or similar.

    Here is a sample implementation (you might just copy it): http://doc.qt.nokia.com/qt-maemo-4.6...resizer-h.html
    this is good stuff, it still doesnt quite work though.. the QTextEdit still creates the scrollbar. Have checked with debugger that the TextEditAutoResizer::textEditChanged() method gets called and it does indeed adjust the minimumHeight of the QTextEdit widget. What I dont understand is why the QScrollArea that contains the QVBoxLayout is not trying to grow... weird.

    Thanks anyways.

  4. #4
    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: multiple textedits inside layouts and scrollarea

    Set the "widgetResizable" property of the scroll area to true.
    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.


Similar Threads

  1. ItemViews in ScrollArea
    By SElsner in forum Newbie
    Replies: 3
    Last Post: 4th June 2010, 23:59
  2. Autoscroll in ScrollArea
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 05:37
  3. Adding spell checking to lineedits, textedits, ...
    By jiveaxe in forum Qt Programming
    Replies: 12
    Last Post: 7th October 2009, 09:04
  4. QSplitter + multiple layouts? how?
    By jalla2000 in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2008, 13:52
  5. Problems putting layouts inside groupbox
    By conexion2000 in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 10:01

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.