void QwtLegendItem::setText(const QwtText &text)
{
    const int flags = Qt::AlignLeft | Qt::AlignVCenter
#if QT_VERSION < 0x040000
        | Qt::WordBreak | Qt::ExpandTabs;
#else
        | Qt::TextExpandTabs | Qt::TextWordWrap;
#endif

    QwtText txt = text;
    txt.setFlags(flags);

    QwtTextLabel::setText(txt);
}
/*!
   Convert a value into its representing label and cache it.

   The conversion between value and label is called very often
   in the layout and painting code. Also the
   calculation of the label sizes might be slow (really slow
   for rich text in Qt4). QwtAbstractScaleDraw::tickLabel
   calls QwtAbstractScaleDraw::label and caches its result.
*/
const QwtText &QwtAbstractScaleDraw::tickLabel(
    const QFont &font, double value) const
{
    QMap<double, QwtText>::const_iterator it = d_data->labelCache.find(value);
    if ( it == d_data->labelCache.end() )
    {
        QwtText lbl = label(value);
        lbl.setFlags(0);
        lbl.setLayoutAttributes(QwtText::MinimumLayout);

        (void)lbl.textSize(font); // initialize the internal cache

        it = d_data->labelCache.insert(value, lbl);
    }

    return (*it);
}