hello, i posted some days ago a problem with that error, but i noticed that i have to use it whit a .h and a separated .cpp, but know i cant find the solution, i just want to create a program to read, edit and update a file, but if i use the Q_OBJECT macro i get that error, i tried include the QObject header,including all widget classes in .h and tried in .cpp and i always get that error, here is my code
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QObject>
  5. #include <QFile>
  6. #include <QDataStream>
  7. #include <QLabel>
  8. #include <QLineEdit>
  9. #include <QTextEdit>
  10. #include <QPushButton>
  11. #include <QWidget>
  12.  
  13. class MainWindow : public QWidget {
  14. Q_OBJECT
  15. public:
  16. MainWindow(QWidget *parent = 0);
  17. private slots:
  18. void openfile();
  19. void updatefile();
  20. private:
  21. QLabel *state;
  22. QLineEdit *filePath;
  23. QTextEdit *fileContent;
  24. QPushButton *open_create;
  25. QPushButton *updateFile;
  26. QFile *file;
  27. };
  28.  
  29. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

and here my constructor
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
  2.  
  3.  
  4. resize(600,500);
  5.  
  6. filePath = new QLineEdit(".\\test.txt",this);
  7. filePath->setGeometry(10,10,400,20);
  8.  
  9. open_create = new QPushButton("Open/Create",this);
  10. open_create->setGeometry(420,10,90,20);
  11. QObject::connect(open_create,SIGNAL(clicked()),this,SLOT(openfile()));
  12.  
  13. updateFile = new QPushButton("Update file",this);
  14. updateFile->setGeometry(520,10,70,20);
  15.  
  16. state = new QLabel("Ready",this);
  17. state->setGeometry(10,40,500,50);
  18. state->setWordWrap(true);
  19. state->setAlignment(Qt::AlignTop);
  20.  
  21. fileContent = new QTextEdit(this);;
  22. fileContent->setGeometry(10,100,580,390);
  23. }
To copy to clipboard, switch view to plain text mode