First of all, thanks for fast reply,
with it I managed to solve this issue. Using setItemAttribute was the correct approach, but at the beginning it did nothing (or so I thought). I had to set attribute and then update Legend, step by step, only then it actually ran. If someone in the future is interested, that's the code:
for (auto item : mPlot->itemList())
{
// code here to find intended item
item->setItemAttribute(item->Legend, state); //state is defined as true or false
mPlot->updateLegend();
break;
}
Thank you for your help .
EDIT:
OK, now I have another problem regarding this issue.
While legend is showing/hiding properly, using solution mentioned above does following thing:
I have signal A (pos. 1) and B (pos. 2) in menu and in legend.
Now I hide A, so A is hidden in menu and in legend, only B is visible.
Then I show A and A is shown again in menu and in legend, but in menu it's on its position while in legend the structure is now B, A (it's reverse).
I assume that
item->setItemAttribute(item->Legend, state);
disables the attribute ergo removes given signal from legend, and showing it means actually "adding it to the legend list".
When I do this with e.g.3 signals, hidden signal, while shown again, goes to the end of the legend.
Am I right here and is there a way to repair that behaviour?
Bookmarks