Hi everyone,

I have a question in "c++ gui programming with qt 4" chapter 5-4 example(Plotter):

[plotter.h]
Qt Code:
  1. #ifndef PLOTTER_H
  2. #define PLOTTER_H
  3.  
  4. //QMap store (key, value) pairs and provides fast lookup of the value associated with a key.
  5. #include <QMap>
  6. #include <QPixmap>
  7. #include <QVector>
  8. #include <QWidget>
  9.  
  10. class PlotSettings;
  11.  
  12. class Plotter : public QWidget {
  13. Q_OBJECT
  14.  
  15. public:
  16. Plotter(QWidget *parent = 0);
  17.  
  18. void setPlotSettings(const PlotSettings &settings);
  19. void setCurveData(int id, const QVector<QPointF> &data);
  20. void clearCurve(int id);
  21. QSize minimumSizeHint() const;
  22. QSize sizeHint() const;
  23.  
  24. protected:
  25. void paintEvent(QPaintEvent *event);
  26. void resizeEvent(QResizeEvent *event);
  27. void mousePressEvent(QMouseEvent *event);
  28. void mouseMoveEvent(QMouseEvent *event);
  29. void mouseReleaseEvent(QMouseEvent *event);
  30. void KeyPressEvent(QkeyEvent *event);
  31. void wheelEvent(QWheelEvent *event);
  32.  
  33. private:
  34. void updateRubberBandRegion();
  35. void refreshPixmap();
  36. void drawGrid(QPainter *painter);
  37. void drawCurves(QPainter *painter);
  38.  
  39. enum { Margin = 50 };
  40.  
  41. QToolButton *zoomInButton;
  42. QToolButton *zoomOutButton;
  43. QMap<int, QVector<QPointF> > curveMap;
  44. QVector<PlotSettings> zoomStack;
  45. int curZoom;
  46. bool rubberBandIsShown;
  47. QRect rubberBandRect;
  48. QPixmap pixmap;
  49. };
  50.  
  51. class PlotSettings {
  52.  
  53. public:
  54. PlotSettings();
  55.  
  56. void scroll(int dx, int dy);
  57. void adjust();
  58. double spanX() const {
  59. return maxX - minX;
  60. }
  61. double spanY() const {
  62. return maxY - minY;
  63. }
  64.  
  65. double maxX;
  66. double minX;
  67. int numXTicks;
  68. double maxY;
  69. double minY;
  70. int numYTicks;
  71.  
  72. private:
  73. static void adjustAxis(double &min, double &max, int &numTicks);
  74. };
  75.  
  76. #endif
To copy to clipboard, switch view to plain text mode 

[plotter.cpp]
Qt Code:
  1. #include <QtGui>
  2. #include <cmath>
  3.  
  4. #include "plotter.h"
  5.  
  6. Plotter::Plotter(QWidget *parent) : QWidget(parent) {
  7. setBackgroundRole(QPalette::Dark);
  8. setAutoFillBackground(true);
  9. setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  10. setFocusPolicy(Qt::StrongFocus);
  11. rubberBandIsShown = false;
  12.  
  13. zoomInButton = new QToolButton(this);
  14. zoomInButton->setIcon(QIcon(":/images/zoomIn.png"));
  15. zoomInButton->adjustSize();
  16. connect(zoomInButton, SIGNAL(clicked()), this, SLOT(zoomIn());
  17.  
  18. zoomOutButton = new QToolButton(this);
  19. zoomOutButton->setIcon(QIcon(":/images/zoomOut.png"));
  20. zoomOutButton->adjustSize();
  21. connect(zoomOutButton, SIGNAL(clicked), this, SLOT(zoomOut));
  22.  
  23. setPlotSettings(PlotSettings());
  24. }
  25.  
  26. ......
To copy to clipboard, switch view to plain text mode 

and i have question in plotter.cpp,
i never include QToolButton class,
why i can use its constructor and function.

Can someone tell me how to solve the problem?
thanks !