Hi everybody,
I would like to know the best way to control/modify elements of my MainWindow class from a QThread class started from the mainwindow.
In particular I only want to append text to the textEdit on the mainwindow and modify the progress bar value, during the QThread calculation.
I tried the heritage method but it doesn't works.
Ex. of my app:
#ifndef HRSMAINWINDOW_H
#define HRSMAINWINDOW_H
#include <QtGui/QMainWindow>
namespace Ui
{
class HRSMainWindowForm;
}
{
Q_OBJECT
public:
HRSMainWindow
(QWidget *parent
= 0);
~HRSMainWindow();
void APT
(QString a
){ //append text to the textEdit ui->textEdit->append(a);
}
private:
Ui::HRSMainWindowForm *ui;
};
#endif // HRSMAINWINDOW_H
#ifndef HRSMAINWINDOW_H
#define HRSMAINWINDOW_H
#include <QtGui/QMainWindow>
namespace Ui
{
class HRSMainWindowForm;
}
class HRSMainWindow : public QMainWindow
{
Q_OBJECT
public:
HRSMainWindow(QWidget *parent = 0);
~HRSMainWindow();
void APT(QString a){ //append text to the textEdit
ui->textEdit->append(a);
}
private:
Ui::HRSMainWindowForm *ui;
};
#endif // HRSMAINWINDOW_H
To copy to clipboard, switch view to plain text mode
#ifndef HRSTHREAD_H
#define HRSTHREAD_H
#include <QThread>
#include "hrsmainwindow.h"
class HRSThread
: public QThread,
public HRSMainWindow
{
public:
void run(){
APT("Hello World"); // don`t work
}
};
#endif // HRSTHREAD_H
#ifndef HRSTHREAD_H
#define HRSTHREAD_H
#include <QThread>
#include "hrsmainwindow.h"
class HRSThread : public QThread, public HRSMainWindow
{
public:
void run(){
APT("Hello World"); // don`t work
}
};
#endif // HRSTHREAD_H
To copy to clipboard, switch view to plain text mode
Thank you very much
Bookmarks