@Jim-G said in QTableView subclass - Am I reinventing the wheel?:
Thanks, I guess I'm a bit surprised this resizing behavior isn't an already-solved problem.
The thing is that there are a lot of ways to solve it, so Qt can't just impose one particular solution. Your solution is one, and appears valid, so if it works for you then you're all good.
A lower-effort solution might be just leaving the column widths static on resize, and only grow/shrink the last column to fit. (Or even leave the last column alone as well, when the container grows, and just extend empty space next to the last column.) On the theory that the sizes for the other columns are probably already adequate for the data they contain — or if not, the user will adjust them as needed.
The data contained in the columns doesn't change size just because the container does, so sizing columns based on ratios often leaves you with either too-wide columns in a very large layout, or too-narrow columns when the table as a whole is shrunk down. In a surprising number of cases, fixed widths turn out to be a more comfortable approach.
But like I said, ultimately which solution is right is up to you.