plotmatrix axes alignment and QwtPlotZoomer
I'm trying to adapt axes alignment code from the PlotMatrix playground example to my application. But It doesn't work as I expect when I add QwtPlotZoomer to the plots.
Problem is when I zoom into a plot with rectangle selection other plots axes aren't updated immediately. And Y axes stay out of alignment. But they are correctly updated when I resize the window.How can I correctly trigger an update on axis widgets?
Problem can be reproduced by adding a QwtPlotZoomer to `Plot` class in plotmatrix playground example. Code:
Code:
public:
{
canvas->setLineWidth( 1 );
setCanvas( canvas );
}
Re: plotmatrix axes alignment and QwtPlotZoomer
Changing the connection to a Qt::QueuedConnection should fix this issue:
Code:
connect( plot->axisWidget( axis ), SIGNAL( scaleDivChanged() ),
SLOT( scaleDivChanged() ), Qt::QueuedConnection );
But don't forget to synchronize the zoom stacks of the various zoomer objects.
Uwe
Re: plotmatrix axes alignment and QwtPlotZoomer
Uwe, thanks for your recommendation. I've worked on it a bit. It seems to work. But in certain cases it doesn't. I've uploaded the plotmatrix.cpp file I modified here: https://gist.github.com/hyOzd/4e3e9f...ff3c57efb9dc56
Let me explain. When I zoom in to one of the plots for the first time, in the first or second row left scales are updated correctly. But third row isn't updated correctly. When I continue zooming deeper, third row is updated correctly and it works fine for all levels. When I unzoom with right click, third row again isn't updated properly. When third row is out of sync, changing the window size fixes the problem. But I've noticed that changing window size should result in a size change in the leftmost plot widget, otherwise it isn't effective.
By the way here is the ZoomGroup class I've added to sync zoom stacks of plot widgets (also present in above gist):
Code:
{
private:
bool inSync = false;
void onZoomed
(const QRectF &rect
) {
if (inSync)
{
qDebug() << "in sync";
return;
}
inSync = true;
Q_ASSERT(source != NULL);
for (int i = 0; i < zoomers.length(); i++)
{
if (source == zoomers[i])
continue;
zoomers[i]->setZoomStack(source->zoomStack(),
source->zoomRectIndex());
}
inSync = false;
}
public:
{
connect(
zoomer, &QwtPlotZoomer::zoomed,
this, &ZoomGroup::onZoomed,
Qt::QueuedConnection);
zoomers.append(zoomer);
}
private:
QList<QwtPlotZoomer*> zoomers;
};