Hi,

I've created a GUI application and I'd like to convert it into a CONSOLE application. I took out some lines (see //) and addes some (see //ADDED). However, the simple test program failed to compile with this error message: "main.cpp:29: error: ‘myFunction’ was not declared in this scope". Below are my main.cpp, functions.cpp and tom.h

main.cpp
Qt Code:
  1. #include <QCoreApplication>//ADD
  2. #include <QApplication>
  3. #include <QtGui>
  4. #include "tom.h"
  5. #include "functions.cpp"
  6.  
  7. MyWidget::MyWidget(QWidget* parent): QWidget(parent)
  8. {
  9. //mainLayout = new QVBoxLayout;
  10. //buttonLayout = new QHBoxLayout;
  11. //runButton = new QPushButton("run");
  12. //connect(runButton, SIGNAL(clicked()), this, SLOT(myFunction()));
  13. //mainLayout->addLayout(buttonLayout);
  14. //buttonLayout->addWidget(runButton);
  15. //setLayout(mainLayout);
  16. }
  17.  
  18. ////////////////////////////////////////////////////////////
  19. int main(int argc, char *argv[])
  20. {
  21. //QApplication application(argc, argv);
  22. QCoreApplication application(argc, argv);//ADD
  23. myFunction();//ADD
  24.  
  25. //Widget window;
  26. //window.show();
  27. //return application.exec();
  28.  
  29. return 0;//ADD
  30. }
To copy to clipboard, switch view to plain text mode 
functions.cpp
Qt Code:
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. /////////////////////////////////////////////////////
  8. void MyWidget::myFunction()
  9. {
  10. FILE *output; if((output=fopen("output.txt","w")) == 0) {exit(1);}
  11. fprintf(output,"hello\n");
  12. fclose(output);
  13. }
To copy to clipboard, switch view to plain text mode 
tom.h
Qt Code:
  1. #ifndef TOM_H
  2. #define TOM_H
  3. #include <QtGui>
  4.  
  5. class MyWidget : public QWidget
  6. {
  7. Q_OBJECT
  8. public:
  9. MyWidget (QWidget* parent = 0);
  10. void myFunction();//ADD
  11.  
  12. public slots:
  13. //void myFunction();
  14.  
  15. signals:
  16.  
  17. protected:
  18.  
  19. private:
  20. //QVBoxLayout* mainLayout;
  21. //QHBoxLayout* buttonLayout;
  22. //QPushButton* runButton;
  23. };
  24.  
  25. #endif
To copy to clipboard, switch view to plain text mode 

I'd be most thankful for any help!