code: def _checkSize(self):
          
          if self._item_height is not None:
              sz = min(self._max_height_items, self.count()) * self._item_height + 5
              sz = max(sz, 20)
              self.setMinimumSize(0, sz)
              self.setMaximumSize(1000000, sz)
              self.resize(self.width(), sz)
docs: Automatically resizes widget to display at most max_height_items items