Hi,
I want to recover the color of the curve for the background legend (<--- ) but any success... 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); <
---
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() );
const QVariant iconValue
= data.
value( QwtLegendData
::IconRole );
if ( iconValue.canConvert<QPixmap>() )
pm = iconValue.value<QPixmap>();
item->setData(pm, Qt::DecorationRole);
}
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);
}
To copy to clipboard, switch view to plain text mode
Thank you for your lights
Bookmarks