Hi,

I plan to write a function for the plot user to customize the style of grids. That is to say, the user can explicitly assign the number of the minor and major grid line. For example, a scale is 150(only considering X-axis) : major ticks is 0, 75, 150, medium ticks is 15, 30, 45, 60, 90, 105, 120, 135, minor ticks is 5, 10, 20, 25, 35, 40... 130, 140, 145 user only is needed to give the number of ticker(3 major ticks, 8 medium ticks and 20 minor tickes)

I met two problem:

1. for the style

grid line of major ticks should be painted in style of Qt::black, 1, Qt::SolidLine, and the medium ticks should be Qt::gray, 1, Qt:ashLine.

I use the qwtplotgrid member function setMajorPen()/setMinorPen() to apply the above style to the grid line, however it shows a unexpected plot grid line. Neither major lines nor minor lines are in correct postions. pls help to find the attchments.

what i get
mygrid.jpg

what i want
grid.jpg

2. for the number(or steps, stepsize)

I use QwtScaleEngine(QwtLinearScaleEngine/QwtLogScaleEngine), but it cannot work out the my ideal tickes as I metioned below.


------------------code------------------
Qt Code:
  1. plots[i] = new QwtPlot(mainFrame);
  2.  
  3. plots[i]->enableAxis(QwtPlot::xBottom, false);
  4. plots[i]->enableAxis(QwtPlot::yRight, false);
  5. plots[i]->enableAxis(QwtPlot::xTop, true);
  6. plots[i]->enableAxis(QwtPlot::yLeft,true);
  7.  
  8. // grid
  9. grids[i] = new QwtPlotGrid();
  10. grids[i]->enableX(true);
  11. grids[i]->enableXMin(true);
  12.  
  13. // for major grid line
  14. grids[i]->setMajorPen(Qt::black, 1, Qt::SolidLine);
  15. // for minor grid line
  16. grids[i]->setMinorPen(Qt::gray, 1, Qt::DashLine);
  17.  
  18. div = lineSE->divideScale(0, 150, 2, 5, 15);
  19.  
  20. plots[i]->setAxisScaleDiv(QwtPlot::xTop, div);
  21.  
  22. grids[i]->attach(plots[i]);
To copy to clipboard, switch view to plain text mode 


Thank you in advance.



Tang Tao