Resizes this widget to fit the contents of its text.

def resizeToContents(self):
        """
        Resizes this widget to fit the contents of its text.
        """
        doc = self.document()
        h = doc.documentLayout().documentSize().height()
        self.setFixedHeight(h + 4)