QTableWidget is a QAbstractScrollArea. The sizeHint() of QTableWidget doesn't take the contents anyhow into account. In fact, QTableWidget, QTableView or QAbstractItemView doesn't even implement sizeHint(). In other words, item views basically don't ask for any specific size because they're happy with what they get. If it's less than the contents require, scroll bars appear.
If you want a QTableWidget size to follow its contents, you should subclass QTableWidget and reimplement sizeHint(). QTableView and QHeaderView provide necessary functions to calculate size of the contents. You might also want to search the forums for more details. This subject has been discussed before.
Bookmarks