In below code I'm trying to set scales for X and Y axis. I use setAxisScale but scale doesn't change and I don't see any curves. I must admit Qwt doesn't have user-friendly designed interface.

Qt Code:
  1. #ifndef PLOT_H
  2. #define PLOT_H
  3.  
  4. #include <qvaluelist.h>
  5.  
  6. #include <qwt_plot.h>
  7. #include <qwt_plot_marker.h>
  8. #include <qwt_plot_curve.h>
  9. #include <qwt_legend.h>
  10. #include <qwt_scale_engine.h>
  11. #include <qwt_data.h>
  12. #include <qwt_text.h>
  13.  
  14. #include <math.h>
  15.  
  16. class Plot : public QwtPlot
  17. {
  18. public:
  19. Plot()
  20. {
  21. curves.setAutoDelete(true);
  22. X.setAutoDelete(true);
  23. Y.setAutoDelete(true);
  24.  
  25. setTitle("A Simple QwtPlot Demonstration");
  26. insertLegend(new QwtLegend(), QwtPlot::RightLegend);
  27.  
  28. // Set axis titles
  29. setAxisTitle(xBottom, "x -->");
  30. setAxisTitle(yLeft, "y -->");
  31. /*
  32. setAxisAutoScale(xBottom);
  33. setAxisAutoScale(xTop);
  34. setAxisAutoScale(yLeft);
  35. setAxisAutoScale(yRight);
  36. */
  37. minX = 0.0;
  38. maxX = 0.0;
  39. minY = 0.0;
  40. maxY = 0.0;
  41.  
  42. setAxisScaleEngine(xBottom, new QwtLinearScaleEngine());
  43. setAxisScaleEngine(yLeft, new QwtLinearScaleEngine());
  44.  
  45. // Insert markers
  46.  
  47. // ...a horizontal line at y = 0...
  48. /*
  49. QwtPlotMarker *mY = new QwtPlotMarker();
  50. mY->setLabel(QString::fromLatin1("y = 0"));
  51. mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  52. mY->setLineStyle(QwtPlotMarker::HLine);
  53. mY->setYValue(0.0);
  54. mY->attach(this);
  55. */
  56.  
  57. // ...a vertical line at x = 2 * pi
  58. /*
  59. QwtPlotMarker *mX = new QwtPlotMarker();
  60. mX->setLabel(QString::fromLatin1("x = 2 pi"));
  61. mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  62. mX->setLineStyle(QwtPlotMarker::VLine);
  63. mX->setXValue(1000.0);
  64. mX->attach(this);
  65. */
  66. }
  67.  
  68. ~Plot()
  69. {
  70. curves.clear();
  71. X.clear();
  72. Y.clear();
  73. }
  74.  
  75. void addCurve(QValueList<double> & list)
  76. {
  77. double * x = new double[list.count()];
  78. double * y = new double[list.count()];
  79.  
  80. for (unsigned int i = 0 ; i < list.count() ; i++)
  81. {
  82. x[i] = i;
  83. y[i] = list[i];
  84. }
  85.  
  86. X.append(x);
  87. Y.append(y);
  88.  
  89.  
  90. c->setRawData(x, y, list.count());
  91. c->attach(this);
  92.  
  93. if (c->minXValue() < minX)
  94. minX = c->minXValue();
  95.  
  96. if (c->maxXValue() > maxX)
  97. maxX = c->maxXValue();
  98.  
  99. if (c->minYValue() < minY)
  100. minY = c->minYValue();
  101.  
  102. if (c->maxYValue() > maxY)
  103. maxY = c->maxYValue();
  104.  
  105. setAxisScale(xBottom, minX, maxX);
  106. setAxisScale(yLeft, minY, maxY);
  107.  
  108. curves.append(c);
  109. }
  110.  
  111. private:
  112. QPtrList<QwtPlotCurve> curves;
  113. QPtrList<double> X;
  114. QPtrList<double> Y;
  115. double minX;
  116. double maxX;
  117. double minY;
  118. double maxY;
  119. };
  120.  
  121. #endif
To copy to clipboard, switch view to plain text mode