<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sizeHint(self):
 """QWidget.sizeHint implementation Automatically resizes the widget according to rows count FIXME very bad algorithm. Remove all this margins, if you can """

        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)