Sailordi, the error is in the way you're including the header files. I did some modifications that should fix it. However I'd like to tell you that what you're doing is not a good programming practice.
MainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui { class MainWindow; }
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
MainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "message_function.h"
message_function MeFu;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MeFu.Print(ui);
}
MainWindow::~MainWindow()
{
delete ui;
}
message_function.h
#ifndef MESSAGE_FUNCTION_H
#define MESSAGE_FUNCTION_H
#include "mainwindow.h"
class message_function
{
public:
void Print(Ui::MainWindow *ui);
};
#endif // MESSAGE_FUNCTION_H
message_function.cpp
#include "message_function.h"
#include "ui_mainwindow.h"
void message_function::Print(Ui::MainWindow* ui)
{
ui->label->setText("This is a test");
}