drunknight
21st April 2014, 05:31
I have written a QwtPlot on MainWindow,and set it as centreWidget.
Here is the code i wrote based on the Qwt examples:
Plot::Plot( QWidget *parent ):
IncrementalPlot( parent ),
d_timer( 0 )
{
enableAxis(xBottom,false);
enableAxis(yLeft,false);
setAxisMaxMajor(xBottom,17);
setAxisMaxMajor(yLeft,10);
d_rescaler = new QwtPlotRescaler( canvas() );
d_rescaler->setReferenceAxis( QwtPlot::xBottom );
d_rescaler->setAspectRatio( QwtPlot::yLeft, 1.0 );
d_rescaler->setAspectRatio( QwtPlot::yRight, 0.0 );
d_rescaler->setAspectRatio( QwtPlot::xTop, 0.0 );
d_rescaler->setRescalePolicy( QwtPlotRescaler::Expanding );
d_rescaler->setEnabled( true );
d_rescaler->rescale();
plotLayout()->setAlignCanvasToScales( true );
QwtPlotGrid *grid = new QwtPlotGrid;
grid->setMajorPen( Qt::black, 0, Qt::SolidLine );
grid->attach( this );
setCanvasBackground( Qt::gray );
setAxisScale( xBottom, 0, 1000 );
setAxisScale( yLeft, 0, 1000 );
canvas()->setMouseTracking(true);
replot();
// panning with the left mouse button
new QwtPlotPanner( canvas() );
// zoom in/out with the wheel
QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
magnifier->setMouseButton( Qt::NoButton );
picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,canvas());
}
I came as:
10294
I would like to keep the grid square.
But when i zoomed in,it became like this:
10295
I have found some information about this,like the grid is bound to the ScaleTicks.
But i still didn't found the solution.Could anyone help me out?@Uwe?
Thanks first!
Here is the code i wrote based on the Qwt examples:
Plot::Plot( QWidget *parent ):
IncrementalPlot( parent ),
d_timer( 0 )
{
enableAxis(xBottom,false);
enableAxis(yLeft,false);
setAxisMaxMajor(xBottom,17);
setAxisMaxMajor(yLeft,10);
d_rescaler = new QwtPlotRescaler( canvas() );
d_rescaler->setReferenceAxis( QwtPlot::xBottom );
d_rescaler->setAspectRatio( QwtPlot::yLeft, 1.0 );
d_rescaler->setAspectRatio( QwtPlot::yRight, 0.0 );
d_rescaler->setAspectRatio( QwtPlot::xTop, 0.0 );
d_rescaler->setRescalePolicy( QwtPlotRescaler::Expanding );
d_rescaler->setEnabled( true );
d_rescaler->rescale();
plotLayout()->setAlignCanvasToScales( true );
QwtPlotGrid *grid = new QwtPlotGrid;
grid->setMajorPen( Qt::black, 0, Qt::SolidLine );
grid->attach( this );
setCanvasBackground( Qt::gray );
setAxisScale( xBottom, 0, 1000 );
setAxisScale( yLeft, 0, 1000 );
canvas()->setMouseTracking(true);
replot();
// panning with the left mouse button
new QwtPlotPanner( canvas() );
// zoom in/out with the wheel
QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
magnifier->setMouseButton( Qt::NoButton );
picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,canvas());
}
I came as:
10294
I would like to keep the grid square.
But when i zoomed in,it became like this:
10295
I have found some information about this,like the grid is bound to the ScaleTicks.
But i still didn't found the solution.Could anyone help me out?@Uwe?
Thanks first!