I have written a QwtPlot on MainWindow,and set it as centreWidget.
Here is the code i wrote based on the Qwt examples:
Qt Code:
  1. Plot::Plot( QWidget *parent ):
  2. IncrementalPlot( parent ),
  3. d_timer( 0 )
  4. {
  5. enableAxis(xBottom,false);
  6. enableAxis(yLeft,false);
  7. setAxisMaxMajor(xBottom,17);
  8. setAxisMaxMajor(yLeft,10);
  9.  
  10. d_rescaler = new QwtPlotRescaler( canvas() );
  11. d_rescaler->setReferenceAxis( QwtPlot::xBottom );
  12. d_rescaler->setAspectRatio( QwtPlot::yLeft, 1.0 );
  13. d_rescaler->setAspectRatio( QwtPlot::yRight, 0.0 );
  14. d_rescaler->setAspectRatio( QwtPlot::xTop, 0.0 );
  15. d_rescaler->setRescalePolicy( QwtPlotRescaler::Expanding );
  16. d_rescaler->setEnabled( true );
  17. d_rescaler->rescale();
  18.  
  19. plotLayout()->setAlignCanvasToScales( true );
  20.  
  21. QwtPlotGrid *grid = new QwtPlotGrid;
  22. grid->setMajorPen( Qt::black, 0, Qt::SolidLine );
  23. grid->attach( this );
  24.  
  25. setCanvasBackground( Qt::gray );
  26.  
  27. setAxisScale( xBottom, 0, 1000 );
  28. setAxisScale( yLeft, 0, 1000 );
  29. canvas()->setMouseTracking(true);
  30. replot();
  31.  
  32. // panning with the left mouse button
  33. new QwtPlotPanner( canvas() );
  34.  
  35. // zoom in/out with the wheel
  36. QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
  37. magnifier->setMouseButton( Qt::NoButton );
  38.  
  39. picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,canvas());
  40. }
To copy to clipboard, switch view to plain text mode 

I came as:
Square.png

I would like to keep the grid square.

But when i zoomed in,it became like this:
Rectangular.png

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!