Hello!

I am trying to paint a simple plot (sin) on a screen.
Maybe my method is a bit wierd I don't know, this is my first paint-expirience.
Hower, I encountered a problem.

Here is my code:

.h
Qt Code:
  1. #ifndef WIDGET_H
  2. #define WIDGET_H
  3.  
  4. #include <QWidget>
  5. #include <QLabel>
  6. #include <QPainter>
  7.  
  8.  
  9.  
  10. class Widget : public QWidget
  11. {
  12. Q_OBJECT
  13. const double pi = 3.14159;
  14. public:
  15. Widget(QWidget *parent = 0);
  16. ~Widget();
  17.  
  18. private:
  19. QLabel *Hi;
  20. QPainter *paint;
  21. virtual void paintEvent(QPaintEvent * );
  22. };
  23.  
  24. #endif // WIDGET_H
To copy to clipboard, switch view to plain text mode 

.cpp
Qt Code:
  1. #include "widget.h"
  2. #include <QWidget>
  3. #include <cmath>
  4.  
  5. Widget::Widget(QWidget *parent)
  6. : QWidget(parent)
  7. {
  8. this->setGeometry(100,100,800,500);
  9. paint = new QPainter(this);
  10. }
  11.  
  12. Widget::~Widget()
  13. {
  14.  
  15. }
  16.  
  17. void Widget::paintEvent(QPaintEvent * )
  18. {
  19. paint-> setPen(QPen(Qt::red));
  20.  
  21. for(int i=0;i<1000;i++)
  22. {
  23. qreal x=sin(pi/6+i);
  24. qreal y=sin(pi/6+i);
  25. paint->drawPoint(QPointF(x,y));
  26. }
  27. }
To copy to clipboard, switch view to plain text mode 

At first, I just tried to paint in .cpp without void Widget::paintEvent(QPaintEvent * ) like this:
Qt Code:
  1. #include "widget.h"
  2. #include <QWidget>
  3. #include <cmath>
  4.  
  5. Widget::Widget(QWidget *parent)
  6. : QWidget(parent)
  7. {
  8. this->setGeometry(100,100,800,500);
  9. paint = new QPainter(this);
  10. paint-> setPen(QPen(Qt::red));
  11.  
  12. for(int i=0;i<1000;i++)
  13. {
  14. qreal x=sin(pi/6+i);
  15. qreal y=sin(pi/6+i);
  16. paint->drawPoint(QPointF(x,y));
  17. }
  18. }
  19.  
  20. Widget::~Widget()
  21. {
  22.  
  23. }
To copy to clipboard, switch view to plain text mode 

It didn't work. Then I looked throught the Internet and found out that one can paint only in void Widget::paintEvent(QPaintEvent * ), and besides this method must be virtual. I have changed this, it didn't help either.

then I found that paint(this) should be changed to this paint.begin(viewport());
done and viewport() "no matching fucntion to call"

What seems to be the problem here? and could someone help me to fix that?
Thank you in advance!