Adjust dialog size to size of data in child QTableView works for width but not height
-
I have a dialog with the following object hiearchy
QDialog layout QVBoxLayout QWidget layout QHBoxLayout QTableViewItem QPushButtonHence fairly simple. The table view shall display a matrix. The size of this matrix may vary. Hence I wish to adjust the the size of the dialog to the data. This I've done by inserting
resize(1,1); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);in the dialog constructor. This works fine for width but the dialog height only becomes enough for a single row. I've tested different layouts and scrutinized all size proprties of the table view and the first child widget. They are the same for both horizontal and vertical and I've tested with both "preferred" and "expanding". Scrollbar settings for the tableview are the same for both horizontal and vertical. Header settings too. But still the dialog doesn't adjust height to number of rows in table.
Why does width and height behaves differently and how can I get the dialog to the right height?