Results 1 to 2 of 2

Thread: How to get a QDockWidget to Autosize For A QTreeView

  1. #1
    Join Date
    Jul 2010
    Location
    United States
    Posts
    13
    Qt products
    Platforms
    Unix/X11 Windows
    Thanks
    4

    Default How to get a QDockWidget to Autosize For A QTreeView

    I am simply adding a QTreeView to a QDockWidget. I want the QDockWidget to resize to the size of the QTreeView. I have tried adding the tree to a widget via layouts. I have tried size policies, etc. etc. I have read that that the QDockWidget resizes to the contents of its item. I can get the size of the tree view and it is certainly not being sized to that by the QDockWidget. This seems like such a silly request, but it I am have an incredibly difficult time getting this to work. Please, no stylesheet solutions. I want to know an elegant programming way to get this QDockWidget to resize. Thanks in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to get a QDockWidget to Autosize For A QTreeView

    There is no natural size for a QTreeView. A QTreeView is a QAbstractScrollArea. It is whatever size you set it to and scroll bars appear if needed to show its contents.

    The dock widget is probably sizing to the sizeHint() returned by the tree view. You could set a minimum or fixed size on the table view.

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

    smhall316 (17th April 2013)

Similar Threads

  1. "Autosize" QLabel according to text?
    By Raadush in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2012, 07:36
  2. Replies: 0
    Last Post: 14th February 2012, 12:07
  3. how can i have QTableWidget with autosize row height
    By solook in forum Qt Programming
    Replies: 2
    Last Post: 19th September 2011, 08:49
  4. Replies: 1
    Last Post: 7th December 2010, 21:46
  5. QDockwidget
    By peace_comp in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 05:19

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.