View Full Version : Removing Legend

20th December 2008, 00:22
Is there a way to remove or hide a Legend once it has been added to a QwtPlot?

I looked at the documentation, but couldn't find anything that did the trick. setHidden(bool) and setVisible(bool) also don't work for this...

Am I being a little slow and missing something simple?


20th December 2008, 09:41
plot->insertLegend(NULL). Guess "delete plot->legend()" will also work, but I havn't checked this.


22nd January 2009, 23:08
Hi again Uwe,

I can't seem to get either of these options to work. Both create a crash in the program.

As soon as I issue the plot->insertLegend(NULL) it crashes, it does compile though

Any thoughts?

23rd January 2009, 06:33
Start the debugger and check where it crashes ( something everyone should do before reporting ).

QwtPlot::insertLegend deletes the legend, that was previously inserted. When you also delete it in your application it might be the reason for the crash.


23rd January 2009, 20:52
Hi Uwe,

Yep, I was running it in debugger and it was crashing. Turns out that the debugger was corrupted and not debugging properly. Fixed now, as is the Legend hiding.