PDA

View Full Version : QwtLegend - set background color



saracaeus
7th December 2013, 11:11
Hello,

I am really desperating, because there is no information available in internet and I am trying since 4 hours to set the background of my QwtLegend from transparent to non transparent. Nothing works so far :(

I guess its a simple thing, so please give me that advice how i can set the background of my QwtLegend item from transparent to any color. Thank you all!

saracaeus

Uwe
7th December 2013, 12:15
The legend widget is a container with some widgets inside. One of them is a scrollview where the legend item widgets are. A QwtPlotLegendItem is a plot item on the canvas and isn't a widget at all.
What element is it, where you want to have a background ?

Uwe

saracaeus
9th December 2013, 10:14
Thank you, Uwe, for your answer. I tried some stuff according to it. I tried already getting the items of the legend with legendItems(), zero itmes are returned, then I tried to set the backgroundRole of the QScrollArea (which is the parent of the contentsWidget()), didnt work. So I really wonder which widget I should take to set the background color.

Sorry for this noobish kind of answer, but I need to modify a library written by somebody else and the original writer has implemented this legend with a QwtLegend. Thats the reason why I really dont know about it.

All I see is a rectangle box where some curve item labels are listet. This rectangle box should be filled with a background color before the curve item labels are drawn, so the grid item behind the legend item doesnt not shine through.

Any help is appreciated.

Uwe
9th December 2013, 14:07
When the legend is on top of the grid item it seems to be something on the canvas. This might be an "external" QwtLegend or a QwtPlotLegendItem ( what is the better implementation ). How to set the background is completely different.

Uwe

saracaeus
10th December 2013, 14:54
Thank you! the hint with the "external" was right... so I found out that it is indeed an external legend and therefore I only have to override the legend's paintEvent() to draw my frame with filled background :)

Cheers!