Columnview delete empty last column
I'm building a columnview in Python for maya. The problems is when there are no more children for an item a final column gets created which is always empty. I found this online and I believe it is the answer but can't get it to work:
Parameters: rootIndex – PySide.QtCore.QModelIndex
Return type: PySide.QtGui.QAbstractItemView
To use a custom widget for the final column when you select an item overload this function and return a widget. index is the root index that will be assigned to the view.
Return the new view. PySide.QtGui.QColumnView will automatically take ownership of the widget.
I haven't quite been able to work it out, so if someone could tell me how to make it so that the last column doesn't appear if there is no items to add I would be very grateful.
Many thanks in advance.