QCustomPlot Discussion and Comments

How to get QCPMarginGroup working across multiple QCustomPlot instances?Return to overview

Other threads seem to indicate it is possible to use margin group across multiple QCustomPlot objects. The advanced axes demo seems to indicate that QCPMarginGroup aligns axes even when it's aligning elements in different grid layouts. But for some reason, it just doesn't seem to work that way for me. I'm using the 2.0.0 beta and Qt 5.5. My toy experiment is at https://github.com/shavera/QCPMarginGroup-Experiment .

Essentially, I make two widgets that each have a QCustomPlot, one of which has a color scale as a second element in its grid layout. I want to align the left and right edges of the two plots. So I make a QCPMarginGroup in the main window, and use it to set the layouts of the two plots created. I've tried a few variations on this, but it just doesn't seem to work the way I'm hoping.

In some experimentation with the example graph (advanced axes), I tried setting the margin group to the right edge of the main widget, and the right edge of the left sub widget, and that didn't indent like I'd hoped to. Which I guess, ultimately makes sense. It's a "margin" matching tool, and the margin on the left subwidget probably does get matched with the main one, but that doesn't account for the other item in its layout's overall position. So it seems that margingroup isn't a 'match any edge with any edge' tool (it doesn't seem advertised to be that anyway), but more of a 'match the exterior edges of a set of graphs'

Have you checked the documentation site of the QCPMarginGroup?
The usage is explained there, I don't think it can be used for multiple widgets.