[Interest] sizeHint for delegates not wqorking

Francis Herne mail at flherne.uk
Tue Jul 3 13:56:56 CEST 2018


On Tuesday, 3 July 2018 03:11:42 BST Frank Rueter | OHUfx wrote:
> Hi all,
> 
> I am having trouble controlling my table view’s column sizes.
> I thought implementing the delegate’s sizeHint was a way to do this but
> it won’t work for me.
> 
> Can somebody please point out what I’m missing?

You must also set an appropriate resize mode for the view.

Adding
`self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)`

to MyView.__init__ should solve your problem.

See http://doc.qt.io/qt-5/qheaderview.html#ResizeMode-enum

-Francis





More information about the Interest mailing list