void QScrollAreaPrivate::updateScrollBars() { Q_Q(QScrollArea); if (!widget) return; QSize p = viewport->size(); QSize m = q->maximumViewportSize(); QSize min = qSmartMinSize(widget); QSize max = qSmartMaxSize(widget); if ((resizable && m.expandedTo(min) == m && m.boundedTo(max) == m) || (!resizable && m.expandedTo(widget->size()) == m)) p = m; // no scroll bars needed if (resizable) widget->resize(p.expandedTo(min).boundedTo(max)); QSize v = widget->size(); hbar->setRange(0, v.width() - p.width()); hbar->setPageStep(p.width()); vbar->setRange(0, v.height() - p.height()); vbar->setPageStep(p.height()); updateWidgetPosition(); }
QSize QGroupBox::sizeHint() const { QFontMetrics fm( font() ); int tw, th; if ( isCheckable() ) { #ifndef QT_NO_CHECKBOX tw = d->checkbox->sizeHint().width() + 2*fm.width( "xx" ); th = d->checkbox->sizeHint().height() + fm.width( QChar(' ') ); #endif } else { tw = fm.width( title() ) + 2 * fm.width( "xx" ); th = fm.height() + fm.width( QChar(' ') ); } QSize s; if ( layout() ) { s = QFrame::sizeHint(); return s.expandedTo( QSize( tw, 0 ) ); } else { QRect r = childrenRect(); QSize s( 100, 50 ); s = s.expandedTo( QSize( tw, th ) ); if ( r.isNull() ) return s; return s.expandedTo( QSize( r.width() + 2 * r.x(), r.height()+ 2 * r.y() ) ); } }
void QScrollAreaPrivate::updateScrollBars() { Q_Q(QScrollArea); if (!widget) return; QSize p = viewport->size(); QSize m = q->maximumViewportSize(); QSize min = qSmartMinSize(widget); QSize max = qSmartMaxSize(widget); if (resizable) { if ((widget->layout() ? widget->layout()->hasHeightForWidth() : widget->sizePolicy().hasHeightForWidth())) { QSize p_hfw = p.expandedTo(min).boundedTo(max); int h = widget->heightForWidth( p_hfw.width() ); min = QSize(p_hfw.width(), qMax(p_hfw.height(), h)); } } if ((resizable && m.expandedTo(min) == m && m.boundedTo(max) == m) || (!resizable && m.expandedTo(widget->size()) == m)) p = m; // no scroll bars needed if (resizable) widget->resize(p.expandedTo(min).boundedTo(max)); QSize v = widget->size(); hbar->setRange(0, v.width() - p.width()); hbar->setPageStep(p.width()); vbar->setRange(0, v.height() - p.height()); vbar->setPageStep(p.height()); updateWidgetPosition(); }
void SizeHandleRect::tryResize(const QSize &delta) { // Try resize with delta against start position QSize newSize = m_startSize + delta; newSize = newSize.expandedTo(m_resizable->minimumSizeHint()); newSize = newSize.expandedTo(m_resizable->minimumSize()); newSize = newSize.boundedTo(m_resizable->maximumSize()); if (newSize == m_resizable->size()) return; if (debugSizeHandle) qDebug() << "SizeHandleRect::tryResize by (" << m_startSize << '+' << delta << ')' << newSize; m_resizable->resize(newSize); m_curSize = m_resizable->size(); }
QSize CQGroupBox:: minimumSizeHint() const { QFontMetrics fm(titleFont_); int baseWidth = fm.width(title_) + 4; int baseHeight = fm.height(); if (isCheckable()) baseWidth += fm.height() + 4; if (isCollapsible()) baseWidth += fm.height(); QSize size; if (! isCollapsed()) { QStyleOptionGroupBox option; size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this); } else { size = QSize(baseWidth, baseHeight); } return size.expandedTo(QWidget::minimumSizeHint()); }
// Build list widget void KCardWidget::insertCardIcons() { // Clear GUI d->ui.list->clear(); // Rebuild list QSize itemSize; foreach(const QString &name, CardDeckInfo::deckNames()) { KCardThemeInfo v = CardDeckInfo::deckInfo(name); // Show only SVG files? if (v.svgfile.isEmpty()) continue; const int iconSize = 48; QPixmap resizedCard = v.preview.scaled(QSize(iconSize, iconSize), Qt::KeepAspectRatio, Qt::SmoothTransformation); QPixmap previewPixmap(iconSize, iconSize); previewPixmap.fill(Qt::transparent); QPainter p(&previewPixmap); p.drawPixmap((iconSize-resizedCard.width())/2, (iconSize-resizedCard.height())/2, resizedCard); p.end(); QListWidgetItem *item = new QListWidgetItem(v.name, d->ui.list); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setToolTip(v.name); item->setData(Qt::DecorationRole, previewPixmap); item->setData(Qt::UserRole, v.noi18Name); itemSize = itemSize.expandedTo(previewPixmap.size()); }
PageWidgetItem * PageWidget::addPage(QWidget *widget, const QString &name, const QIcon &icon, const QString &header) { PageWidgetItem *page=new PageWidgetItem(stack, header, icon, widget, showHeaders); QListWidgetItem *listItem=new QListWidgetItem(name, list); listItem->setIcon(icon); stack->addWidget(page); list->addItem(listItem); int rows = list->model()->rowCount(); int width = 0; for (int i = 0; i < rows; ++i) { QSize rowSize=list->sizeHintForIndex(list->model()->index(i, 0)); width = qMax(width, rowSize.width()); } width+=static_cast<PageWidgetItemDelegate *>(list->itemDelegate())->standardList() ? 8 : 25; list->setFixedWidth(width); QSize stackSize = stack->size(); for (int i = 0; i < stack->count(); ++i) { const QWidget *widget = stack->widget(i); if (widget) { stackSize = stackSize.expandedTo(widget->minimumSizeHint()); } } setMinimumHeight(qMax(minimumHeight(), stackSize.height())); setMinimumWidth(qMax(minimumWidth(), stackSize.width()+width+layout()->spacing())); list->setCurrentRow(0); stack->setCurrentIndex(0); pages.insert(listItem, page); return page; }
/*! Calculate the size for a arrow that fits into a rect of a given size \param arrowType Arrow type \param boundingSize Bounding size \return Size of the arrow */ QSize QwtArrowButton::arrowSize(Qt::ArrowType arrowType, const QSize &boundingSize) const { QSize bs = boundingSize; if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) bs.transpose(); const int MinLen = 2; const QSize sz = bs.expandedTo( QSize(MinLen, 2 * MinLen - 1)); // minimum int w = sz.width(); int h = 2 * w - 1; if ( h > sz.height() ) { h = sz.height(); w = (h + 1) / 2; } QSize arrSize(w, h); if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) arrSize.transpose(); return arrSize; }
QSize TileLayout::sizeHint() const { QSize size; for (const QLayoutItem* item : qAsConst(m_items)) size = size.expandedTo(item->sizeHint()); return size; }
// Return the maximum size of any widget. QSize PackedLayout::minimumSize() const { QSize size; for (int i = 0, end = mItems.count(); i < end; ++i) size = size.expandedTo(mItems[i]->minimumSize()); int m = margin() * 2; return QSize(size.width() + m, size.height() + m); }
QSize TickSlider::sizeHint() const { QSize size = QSlider::sizeHint(); bool using_labels = tickLabelPosition() != NoTicks; QSize label = using_labels ? biggestLabel() : QSize(); bool using_ticks = tickPosition() != NoTicks; int n_potential_labels = (maximum() - minimum()) / tickInterval(); if (orientation() == Qt::Horizontal) { // Horizontal if (using_labels) { size.rheight() += 2 * label.height(); size = size.expandedTo(QSize( n_potential_labels * label.width() + (n_potential_labels - 1) * m_min_interlabel_gap, 0)); } if (using_ticks) { size.rheight() += 2 * m_tick_length; } if (using_labels && using_ticks) { size.rheight() += 2 * m_tick_label_gap; } if (using_labels || using_ticks) { size.rheight() += 2 * m_gap_to_slider; } } else { // Vertical if (using_labels) { size.rwidth() += 2 * label.width(); size = size.expandedTo(QSize( 0, n_potential_labels * label.height() + (n_potential_labels - 1) * m_min_interlabel_gap)); } if (using_ticks) { size.rwidth() += 2 * m_tick_length; } if (using_labels && using_ticks) { size.rwidth() += 2 * m_tick_label_gap; } if (using_labels || using_ticks) { size.rwidth() += 2 * m_gap_to_slider; } } return size; }
QSize FlowLayout::minimumSize() const { QSize size; for (QLayoutItem *item : m_item_list) size = size.expandedTo(item->minimumSize()); size += QSize(2 * margin(), 2 * margin()); return size; }
void QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint() { Q_Q(QProgressDialog); QSize size = q->sizeHint(); if (q->isVisible()) size = size.expandedTo(q->size()); q->resize(size); }
void WidgetGraphicsItem::setWidget( QWidget *widget ) { d->m_widget = widget; QSize size = widget->sizeHint().expandedTo( widget->size() ); size = size.expandedTo( widget->minimumSize() ); size = size.boundedTo( widget->maximumSize() ); setSize( size ); widget->resize( size ); }
QSize SideBySideLayout::sizeHint() const { QSize sh; foreach( QLayoutItem* i, m_itemList ) sh = sh.expandedTo( i->sizeHint() ); return sh; }
QSize FixedSizeGridLayout::minimumSize() const { QSize size; for (QLayoutItem *item : m_items) size = size.expandedTo(item->minimumSize()); size += QSize(2 * margin(), 2 * margin()); return size; }
/*! \brief Set the slider's handle size \param size New size \sa handleSize() */ void QwtSlider::setHandleSize( const QSize &size ) { const QSize handleSize = size.expandedTo( QSize( 8, 4 ) ); if ( handleSize != d_data->handleSize ) { d_data->handleSize = handleSize; layoutSlider( true ); } }
void UBFloatingPalette::adjustSizeAndPosition(bool pUp, bool resetPosition) { QSize newPreferredSize = preferredSize(); foreach (UBFloatingPalette* palette, mAssociatedPalette) { QSize palettePreferredSize = palette->preferredSize(); newPreferredSize.setWidth(newPreferredSize.expandedTo(palettePreferredSize).width()); }
QSize FlowLayout::minimumSize() const { QSize size; QLayoutItem *item; foreach (item, itemList) size = size.expandedTo(item->minimumSize()); size += QSize(2*margin(), 2*margin()); return size; }
QSize SideBySideLayout::minimumSize() const { QSize minSize; foreach( QLayoutItem* i, m_itemList ) minSize = minSize.expandedTo( i->minimumSize() ); return minSize; }
QSize TickSlider::biggestLabel() const { QSize maxsize; QFontMetrics fm = fontMetrics(); for (const QString& label : m_tick_labels) { QSize labelsize = fm.size(Qt::TextSingleLine, label); maxsize = maxsize.expandedTo(labelsize); } return maxsize; }
QSize EvButton::sizeHint() const { ensurePolished(); QSize s = fontMetrics().size(Qt::TextSingleLine, text()); s *= 1.1; s.rheight() += 4; s.rwidth() += s.height(); return s.expandedTo(QApplication::globalStrut()); }
void MythUIType::ExpandArea(const MythRect &rect) { QSize childSize = rect.size(); QSize size = m_Area.size(); if (childSize == size) return; SetSize(size.expandedTo(childSize)); SetRedraw(); }
QSize TileLayout::minimumSize() const { QSize size; for (const QLayoutItem* item : qAsConst(m_items)) size = size.expandedTo(item->minimumSize()); if (!size.isValid()) return QLayout::minimumSize(); return size; }
QSize MonitorLayout::minimumSize() const { QSize size; QLayoutItem* item; foreach (item, m_items) size = size.expandedTo(item->minimumSize()); size += QSize(2 * margin(), 2 * margin()); return size; }
QSize FlowLayout::minimumSize() const { QSize size; QLayoutItem *item; Q_FOREACH ( item, itemList ) size = size.expandedTo ( item->minimumSize() ); int left, top, right, bottom; getContentsMargins ( &left, &top, &right, &bottom ); size += QSize ( left + right, top + bottom ); return size; }
static QSize minSize( const QWidget *w ) { QSize min = w->minimumSize(); QSize s; if ( min.height() <= 0 || min.width() <= 0 ) s = w->minimumSizeHint(); if ( min.height() > 0 ) s.setHeight( min.height() ); if ( min.width() > 0 ) s.setWidth( min.width() ); return s.expandedTo(QSize(0,0)); }
//----------------------------------------------------------------------------- QSize ctkCollapsibleButton::sizeHint()const { Q_D(const ctkCollapsibleButton); QSize buttonSize = this->buttonSizeHint(); if (d->Collapsed) { return buttonSize + QSize(0,d->CollapsedHeight); } // open // QAbstractButton works well only if a layout is set QSize s = this->QAbstractButton::sizeHint(); return s.expandedTo(buttonSize + QSize(0, d->CollapsedHeight)); }
//! Return a size hint QSize QwtLegendLabel::sizeHint() const { QSize sz = QwtTextLabel::sizeHint(); sz.setHeight( qMax( sz.height(), d_data->icon.height() + 4 ) ); if ( d_data->itemMode != QwtLegendData::ReadOnly ) { sz += buttonShift( this ); sz = sz.expandedTo( QApplication::globalStrut() ); } return sz; }
QSize FlowLayout::minimumSize() const { QSize size; QLayoutItem *item; foreach (item, itemList) size = size.expandedTo(item->minimumSize()); int left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); const int margin = left; size += QSize(2*margin, 2*margin); return size; }