code: def sizeHint(self):
          
          width = max([self.fontMetrics().width(word) \
                          for word in self.model().words])
          width = width * 1.4  # FIXME bad hack. invent better formula
          width += 30  # margin
  
          # drawn with scrollbar without +2. I don't know why
          rowCount = min(self.model().rowCount(), self._MAX_VISIBLE_ROWS)
          height = self.sizeHintForRow(0) * (rowCount + 0.5)  # + 0.5 row margin
  
          return QSize(width, height)
docs: QWidget.sizeHint implementation
          Automatically resizes the widget according to rows count
  
          FIXME very bad algorithm. Remove all this margins, if you can