code: def sizeHint(self, option, index):
          
          if self._widget is None:
              return super(WidgetDelegate, self).sizeHint(option, index)
  
          self.set_widget_index(index)
          self._widget.resize(option.rect.size())
          sh = self._widget.sizeHint()
          return sh
docs: Return the appropriate amount for the size of the widget
  
          The widget will always be expanded to at least the size of the viewport.
  
          :param option: the options for painting
          :type option: :class:`QtGui.QStyleOptionViewItem`
          :param index: the index to paint
          :type index: :class:`QtCore.QModelIndex`
          :returns: None
          :rtype: None
          :raises: None