dasycarpum
14th September 2014, 15:08
Hi,
I want to recover the color of the curve for the background legend (<--- ) but any success...:confused: For the title, it's OK :)
void Legend::updateItem( QStandardItem *item, const QwtLegendData &data )
{
const QVariant titleValue = data.value( QwtLegendData::TitleRole );
const QVariant colorValue = data.value(QwtLegendData::IconRole); <---
QwtText title;
if ( titleValue.canConvert<QwtText>() )
{
item->setText( title.text() );
title = titleValue.value<QwtText>();
}
else if ( titleValue.canConvert<QString>() )
{
title.setText( titleValue.value<QString>() );
}
item->setText( title.text() );
item->setBackground(QBrush(QColor(colorValue.Color))); <---
const QVariant iconValue = data.value( QwtLegendData::IconRole );
QPixmap pm;
if ( iconValue.canConvert<QPixmap>() )
pm = iconValue.value<QPixmap>();
item->setData(pm, Qt::DecorationRole);
}
Thank you for your lights
I want to recover the color of the curve for the background legend (<--- ) but any success...:confused: For the title, it's OK :)
void Legend::updateItem( QStandardItem *item, const QwtLegendData &data )
{
const QVariant titleValue = data.value( QwtLegendData::TitleRole );
const QVariant colorValue = data.value(QwtLegendData::IconRole); <---
QwtText title;
if ( titleValue.canConvert<QwtText>() )
{
item->setText( title.text() );
title = titleValue.value<QwtText>();
}
else if ( titleValue.canConvert<QString>() )
{
title.setText( titleValue.value<QString>() );
}
item->setText( title.text() );
item->setBackground(QBrush(QColor(colorValue.Color))); <---
const QVariant iconValue = data.value( QwtLegendData::IconRole );
QPixmap pm;
if ( iconValue.canConvert<QPixmap>() )
pm = iconValue.value<QPixmap>();
item->setData(pm, Qt::DecorationRole);
}
Thank you for your lights