Hi
I want to compile I get following errors:

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall MyNumber::MyNumber(class QObject *)" (??0MyNumber@@QAE@PAVQObject@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)
debug\20.exe:-1: error: LNK1120: 1 unresolved externals
mainwindow.h

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include "mynumber.h"
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit MainWindow(QWidget *parent = 0);
  16. ~MainWindow();
  17. MyNumber *ptr ;
  18. public slots:
  19. void oneNumberChanged(int);
  20. private slots:
  21. void on_pushButton_clicked();
  22.  
  23. void on_pushButton_2_clicked();
  24.  
  25. private:
  26. Ui::MainWindow *ui;
  27. };
  28.  
  29. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include "mynumber.h"
  4.  
  5. MainWindow::MainWindow(QWidget *parent) :
  6. QMainWindow(parent),
  7. ui(new Ui::MainWindow)
  8. {
  9. ui->setupUi(this);
  10. ptr = new MyNumber(this);
  11. connect(ptr,SIGNAL(numberChange(int)),this,SLOT(oneNumberChanged()));
  12. }
  13.  
  14. MainWindow::~MainWindow()
  15. {
  16. delete ui;
  17. }
  18.  
  19. void MainWindow::oneNumberChanged(int number)
  20. {
  21. ui->label->setText(QString::number(number));
  22. }
  23. void MainWindow::on_pushButton_clicked()
  24. {
  25. ptr->start();
  26. }
  27.  
  28. void MainWindow::on_pushButton_2_clicked()
  29. {
  30. ptr->stop = true;
  31. }
To copy to clipboard, switch view to plain text mode 

mynumber.h
Qt Code:
  1. #ifndef MYNUMBER_H
  2. #define MYNUMBER_H
  3.  
  4. #include <QThread>
  5.  
  6. class MyNumber : public QThread
  7. {
  8. Q_OBJECT
  9. public:
  10. explicit MyNumber(QObject *parent = 0);
  11. void run();
  12. bool stop;
  13.  
  14.  
  15. signals:
  16. void numberChange(int);
  17. public slots:
  18.  
  19. };
  20.  
  21. #endif // MYNUMBER_H
To copy to clipboard, switch view to plain text mode 


mynumber.cpp
Qt Code:
  1. #include "mynumber.h"
  2. #include <QMutex>
  3.  
  4. MyNumber::MyNumber(QObject *parent) :
  5. QThread(parent)
  6. {
  7. }
  8.  
  9. void MyNumber::run()
  10. {
  11. for (int i=0 ; i<1000 ; i++)
  12. {
  13. QMutex mutex ;
  14. mutex.lock();
  15. if(this->stop)
  16. break;
  17. mutex.unlock();
  18.  
  19. emit numberChange(i);
  20. this->msleep(1);
  21. }
  22. }
To copy to clipboard, switch view to plain text mode 

Tnx