PDA

View Full Version : How to set the same width axesLabels of 2 QwtPlot



dqrest
6th December 2012, 14:45
Hi)I use qwt-6.0.1. For example, I have 2 QwtPlot which one of them situated above the one. The yAxis of the first one belong to [0,1] and the second one belong to [1000, 9999999]. That's why, the canvases of QwtPlots don't situate smoothly. I see the example "plotmatrix" which demonstrate this problem. But it is too hard to understand how to solve it. Please, could you show the simple example how to solve it , for instance. for yLeft axes and explain the plan how to do it.Please, help.

dqrest
7th December 2012, 07:54
I have solved this problem without axisTitle. The decision is(I have taken it from "plotmatrix" example)
void PlotMatrix::alignVAxes(int col, int axis)
{
if ( axis != QwtPlot::yLeft && axis != QwtPlot::yRight )
return;

int maxExtent = 0;
for ( int row = 0; row < numRows(); row++ )
{
QwtPlot *p = plot(row, col);
if ( p )
{
QwtScaleWidget *scaleWidget = p->axisWidget(axis);

QwtScaleDraw *sd = scaleWidget->scaleDraw();
sd->setMinimumExtent(0);

const int extent = sd->extent(
QPen(Qt::black, scaleWidget->penWidth()),
scaleWidget->font() );
if ( extent > maxExtent )
maxExtent = extent;
}
}
for ( int row = 0; row < numRows(); row++ )
{
QwtPlot *p = plot(row, col);
if ( p )
{
QwtScaleWidget *scaleWidget = p->axisWidget(axis);
scaleWidget->scaleDraw()->setMinimumExtent(maxExtent);
}
}
}