QCustomPlot Discussion and Comments

Hiding QCPLayerables and grid recalculationReturn to overview

Hello. Let's look at such situation: I have one QCustomPlot widget with multiple QCPAxisRect-s in QCPLayerGrid in one column. I'd like to hide some AxisRect. If I just call "someAxisRect->setVisible(false)" it will disappear, but plot will have white space instead of it. I don't know any method to collapse this space. I tried to do this:
//in hide method
someAxisRect->setVisible(false);
someAxisRect->layout()->take(someAxisRect);
ui->plot->plotLayout()->simplify();

//in show method
plot->plotLayout()->insertRow(row);
plot->plotLayout()->addElement(row,0,someAxisRect);
someAxisRect->setVisible(true);

It works, but I'm not sure it's a proper way, because if I don't change visibility taken AxisRect is still painted under another AxisRect and responds to interactions (selection, e.g.). Any help appreciated.

Hi,

The way you do it is the correct way. The reason the axis rect is still visible in the background if you just remove it from the layout is that layouts control positioning/sizing. So upon removal, the axis rect just keeps its last position and size but gets drawn nevertheless (it hasn't been removed from the plot or set invisible so that's why it's still hanging around there).

This is somewhat unintuitive behaviour, I agree. I'm thinking about making layout elements that don't have a parent layout invisible automatically, so maybe this will change in a future QCustomPlot release.

Many thanks for your help.

Hi
I'm just wondering if there is a new way of doing this with QCustomPlot2.0. Did you change the layout elements or is Phyzic code still the correct way?
Cheers!