ich möchte gern von einem Thread auf den Mainthread (GUI) zugreifen mittels "PostMessage()". Hierbei wird nicht direkt ein Widget angesprochen, sondern ich möchte gern eine Methode einer anderen Klasse ansprechen.
Ich hab gerade die QMetaObject::invokeMethod() Methode ausprobiert - innerhalb einer class kein Problem, aber zwischen zwei Klassen?
Code: Alles auswählen
class QtTestApp: public QMainWindow
{
Q_OBJECT
public:
QtTestApp(QWidget *parent = 0, Qt::WFlags flags = 0);
~QtTestApp();
public:
void MyMethod(QString &str);
};
Code: Alles auswählen
class UdpThread : public QThread
{
Q_OBJECT
public:
UdpThread(QObject *parent);
~UdpThread();
public:
virtual void run();
private slots:
void readData();
};
void UdpThread::readData()
{
bool rtn = QMetaObject::invokeMethod(this, "MyMethod", Qt::QueuedConnection, Q_ARG("myString"));
}
Gruß
saoirse