Hello. I'm using QCPLayoutGrid to arrange 4 elements in one plot.
mPlot->plotLayout()->clear(); QCPMarginGroup* marginGroup = new QCPMarginGroup(mPlot); subLayout = new QCPLayoutGrid; for (int i = 0; i < 4; ++i) { QCPAxisRect *subRectLeft = new QCPAxisRect(mPlot, false); subRectLeft->addAxes(QCPAxis::atBottom | QCPAxis::atLeft); subRectLeft->axis(QCPAxis::atLeft)->ticker()->setTickCount(2); subLayout->addElement(i, 0, subRectLeft); subRectLeft->setMarginGroup(QCP::msLeft, marginGroup); } mPlot->plotLayout()->addElement(0, 0, subLayout);
I also need to dynamically hide/show elements in the layout.
auto* it = subLayout->elementAt(idx); it->setVisible(enabled); subLayout->updateLayout(); mPlot->replot();
When an item is hidden, the layout has empty space, i.e. visible elements are not resized to fill the gap https://postimg.cc/14RkN0JM. Is it possible to fill the gap? Or do I need to re-implement the resizing within QCPLayoutGrid and QCPLayout?
Thank you in advance.