/*!
  \return The preferred height, for the width w.
*/
int QwtLegend::heightForWidth(int w) const
{
    w -= 2 * frameWidth();

    int h = d_data->view->contentsWidget->heightForWidth(w);
#if QT_VERSION < 0x040000

    // Asking the layout is the default implementation in Qt4 

    if ( h <= 0 ) 
    {
        QLayout *l = d_data->view->contentsWidget->layout();
        if ( l && l->hasHeightForWidth() )
            h = l->heightForWidth(w);
    }
#endif
    if ( h >= 0 )
        h += 2 * frameWidth();

    return h;
}