Finally I achieved that, but I do not know if the solution is very elegant...
From the main I have passed to the Thread the reference of MainWindow:
Code:
class MyThread : public QThread
{
Q_OBJECT
public:
MyThread(QObject* parent = 0);
virtual ~MyThread();
public: // From QThread
void run();
QString str;
MainWindow *w;
signals:
void sendString(const QString &str);
public slots:
private:
};
Main:
Code:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
MyThread *thread;
w.show();
thread = new MyThread();
thread->w=&w;
thread->start();
//thread.wait();
return a.exec();
}
And I connect this way in MyThread.cpp
Code:
QObject::connect(this, SIGNAL(sendString(const QString &)),
w, SLOT(display(const QString &)));