I have a QTreeView (or a QTableView) and a QScrollArea(which contains a chart) inside a QSplitter, which is set as the widget for the QMdiSubWindow (subclass).

The chart has a minimum size with which i set a minimum size for the scroll area.
The model for the view contains data from the database (whose number of rows differs. Number of columns is the same). I dont want to show the scroll bars on the table if i can fit the mdi subwindow within the main window. if i cannot fit it, showing scrollbars is fine.
Also i want to set the size for the sub window inside the class constructor. Is it possible? Or, how do i set a proper size for the sub window before showing it the first time?

If i put in a QTreeView, i cannot find the width required for all the columns put together. (it always returns 480.) even if i do resizeColumnToContents(.) for all the columns.