Results 1 to 3 of 3

Thread: Setting the recommended size/sizeHint on QTextEdit

  1. #1
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Setting the recommended size/sizeHint on QTextEdit

    I've put 3 QTextEdits above each other in a widget using a QVBoxLayout.
    The one that has input focus is supposed to be bigger than the other two, and I fix that by giving it a stretch factor of 1, while the others have a stretch factor of 0 in the layout.
    That works, but the two QTextEdits that do not have any stretch become too large.
    I suppose they have the default/recommended/preferred/sizeHint-size (whichever is the correct term) of 192 vertical pixels.
    How can I change this default size? There does not seem to be a QWidget::setSizeHint() method, and overriding sizeHint() in a subclass did not help either (it never gets called)

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

    Default Re: Setting the recommended size/sizeHint on QTextEdit

    I suggest you set stretch factors to 2 and 1 respectively. Setting it to 0 doesn't make much sense.
    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:

    drhex (29th June 2011)

  4. #3
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Setting the recommended size/sizeHint on QTextEdit

    I thought that any non-essential space would be distributed such that every widget got (its own stretch)/(the sum of all stretches)*(the number of pixels to distribute)
    Then, 0 would make sense as a stretch factor, as a way of saying "I don't want any extra space".
    But that's apparently not how it works.
    With stretch == 1 for the small QTextEdits and a large value like 100 for the big in-focus one, the small ones shrink to their minimumSize, which works fine for me.

Similar Threads

  1. Setting focus to top of QTextEdit
    By Jon Heron in forum Newbie
    Replies: 1
    Last Post: 25th October 2010, 19:56
  2. Improper size issue in QWidget::sizeHint()
    By George Neil in forum Qt Programming
    Replies: 2
    Last Post: 23rd September 2009, 05:37
  3. Setting SizeHint in QTreeView.
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 3rd August 2009, 11:03
  4. Setting a cursor on QTextEdit
    By Erlendhg in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2007, 17:53
  5. QTextEdit, sizeHint, QWidget
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2007, 08:25

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.