Hi! I am creating two QCustomPlots inside a vertical QSplitter. The main aim is to make the two plots behave just like two QWidgets seperated by a QSplitter and since QCustomPlot doesn't have a splitter I am forced to use Qt's QSplitter which results in two different QWidgets being promoted to QCustomPlot. Usually, it works fine but when I set the margins by myself using
setMargins()function the height ratios of both plots change, ideally both are supposed to have the same height. My Code:
ui.curPlot->axisRect()->setAutoMargins(QCP::msNone); // Plot in the bottom half of vertical QSplitter ui.vltPlot->axisRect()->setAutoMargins(QCP::msNone); // Plot in the top half of vertical QSplitter // Inclusion of the either of the below two lines of code changes the height ratio ui.curPlot->axisRect()->setMargins(QMargins(75, 1, 10, 45)); // Makes curPlot larger in height ui.vltPlot->axisRect()->setMargins(QMargins(75, 10, 10, 1)); // Makes vltPlot larger in height
if both of the
setMargins() lines are included then
curPlot has a larger height than
I can fix it to approximately equal height by manually changing the Stretch Factor of my QSplitter like this:
ui.splitter->setStretchFactor(0, 10); // Changing the stretch factor of vltPlot ui.splitter->setStretchFactor(1, 7); // Changing the stretch factor of curPlotDoes anyone know why is this happening and how can I fix it?