def minimumSize(self): size = QSize() for item in self.items: size = size.expandedTo(item.minimumSize()) margin = self.margin() size += QSize(2*margin, 2*margin) return size
def sizeHint(self): """ A virtual method implementation which returns the size hint for the layout. """ if self._cached_hint is None: size = QSize(0, 0) for item in self._items: size = size.expandedTo(item.sizeHint()) left, top, right, bottom = self.getContentsMargins() size.setWidth(size.width() + left + right) size.setHeight(size.height() + top + bottom) self._cached_hint = size return self._cached_hint
def cellSize(self, leafIndex, hv, styleOptions): res = QSize() variant = leafIndex.data(Qt.SizeHintRole) if variant: res = variant fnt = QFont(hv.font()) var = leafIndex.data(Qt.FontRole) if var: fnt = var fnt.setBold(True) fm = QFontMetrics(fnt) size = QSize(fm.size(0, leafIndex.data(Qt.DisplayRole))+QSize(4, 0)) #WA: add more horizontal size (4px) if leafIndex.data(Qt.UserRole): size.transpose() decorationsSize = QSize(hv.style().sizeFromContents(QStyle.CT_HeaderSection, styleOptions, QSize(), hv)) emptyTextSize = QSize(fm.size(0, "")) return res.expandedTo(size+decorationsSize-emptyTextSize)
def minimumSize(self): """ A reimplemented method which returns the minimum size hint of the layout item widget as the minimum size of the window. """ if self._cached_min is None: size = QSize(0, 0) for item in self._items: size = size.expandedTo(item.minimumSize()) left, top, right, bottom = self.getContentsMargins() size.setWidth(size.width() + left + right) size.setHeight(size.height() + top + bottom) self._cached_min = size # XXX hack! We really need hasWidthForHeight! This doesn't quite # work because a QScrollArea internally caches the min size. d = self._options.direction if d == self.TopToBottom or d == self.BottomToTop: m = QSize(self._cached_min) if m.width() < self._cached_wfh: m.setWidth(self._cached_wfh) return m return self._cached_min
def sizeHint(self): size = QSize(400, 300) return size.expandedTo(QApplication.globalStrut())