PDA

View Full Version : How to get a QDockWidget to Autosize For A QTreeView



smhall316
17th April 2013, 02:44
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

ChrisW67
17th April 2013, 04:35
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.