Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QSize QAbstractSpinBox::minimumSizeHint (  )  const [virtual, inherited]

Reimplemented from QWidget.

Definition at line 787 of file qabstractspinbox.cpp.

References QWidget::ensurePolished(), QSize::expandedTo(), QWidget::fontMetrics(), QStyleOption::rect, QWidget::rect, QRect::setSize(), QRect::size(), QStyle::sizeFromContents(), QWidget::style(), QStyle::subControlRect(), and QFontMetrics::width().

{
    Q_D(const QAbstractSpinBox);
    ensurePolished();

    const QFontMetrics fm(fontMetrics());
    int h = d->edit->minimumSizeHint().height();
    int w = fm.width(QLatin1String("1000"));
    w += 2; // cursor blinking space

    QStyleOptionSpinBox opt = d->getStyleOption();
    QSize hint(w, h);
    QSize extra(35, 6);
    opt.rect.setSize(hint + extra);
    extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
                                            QStyle::SC_SpinBoxEditField, this).size();
    // get closer to final result by repeating the calculation
    opt.rect.setSize(hint + extra);
    extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
                                               QStyle::SC_SpinBoxEditField, this).size();
    hint += extra;

    opt.rect = rect();

    return style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this)
        .expandedTo(QApplication::globalStrut());
}


Generated by  Doxygen 1.6.0   Back to index