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

int QFontMetrics::width ( const QString text,
int  len = -1 
) const

Returns the width in pixels of the first len characters of text. If len is negative (the default), the entire string is used.

Note that this value is not equal to boundingRect().width(); boundingRect() returns a rectangle describing the pixels this string will cover whereas width() returns the distance to where the next string should be drawn.

See also:
boundingRect()

Definition at line 531 of file qfontmetrics.cpp.

References QString::length().

Referenced by Q3DataTable::adjustColumn(), QTextDocument::adjustSize(), Q3Header::changeEvent(), Q3TextEdit::changeEvent(), charWidth(), QPlastiqueStyle::drawControl(), QCalendarWidget::minimumSizeHint(), QGroupBox::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), Q3TextEdit::optimCharIndex(), Q3TextEdit::optimDoAutoScroll(), Q3TextEdit::optimInsert(), Q3TextEdit::optimSetText(), Q3ListViewItem::paintCell(), MandelbrotWidget::paintEvent(), CharacterWidget::paintEvent(), WigglyWidget::paintEvent(), Q3CheckListItem::paintFocus(), Q3ListView::reconfigureItems(), QWindowsStyle::sizeFromContents(), QProgressBar::sizeHint(), Q3TableItem::sizeHint(), Q3Header::sizeHint(), Q3TimeEdit::sizeHint(), Q3DateEdit::sizeHint(), QAbstractSpinBox::sizeHint(), Q3ComboBox::sizeHint(), QDateTimeEdit::sizeHint(), QCommandLinkButton::sizeHint(), QLineEdit::sizeHint(), Q3ProgressBar::sizeHint(), QFontComboBox::sizeHint(), QToolButton::sizeHint(), MainWindow::sizeHint(), Q3ListViewItem::width(), Q3ListBoxPixmap::width(), and Q3ListBoxText::width().

{
    if (len < 0)
        len = text.length();
    if (len == 0)
        return 0;

    QTextEngine layout(text, d);
    layout.ignoreBidi = true;
    layout.itemize();
    return qRound(layout.width(0, len));
}


Generated by  Doxygen 1.6.0   Back to index