Ah. I think I figured it out; the QtConstraintsWidget automatically calls the sizeHint() method of its widget member. It looks like QTableView's sizeHint() method is lame, so I overrode it:
class QJTableView(QTableView):
'''Subclass QTableView to customize size hints'''
def sizeHint(self):
x_fudge_width = 2
y_fudge_width = 2
# No idea where these magic numbers come from, or how they vary on different systems
xfull = self.horizontalHeader().length() + self.verticalHeader().sizeHint().width() + x_fudge_width
yfull = self.verticalHeader().length() + self.horizontalHeader().sizeHint().height() + y_fudge_width
# If they are smaller, the scrollbars appear, and then we'd need to add room for the scrollbars,
# in which case the scrollbars would disappear.
x = xfull + self.verticalScrollBar().sizeHint().width()
# Make room for up to the first 12 columns
y = self.horizontalHeader().sizeHint().height() + y_fudge_width
m = self.model()
if m is not None:
y += sum(self.rowHeight(r) for r in xrange(min(12,m.rowCount())))
sz = QSize(x,y)
return sz