C++ (Qt)class WorkThread : public QThread{ Q_OBJECTpublic: explicit WorkThread(QObject *parent = 0); protected: void run(); signals: void SendStr(const QString str); public slots: };
C++ (Qt)namespace Ui {class MyWidget;} class MyWidget : public QWidget{ Q_OBJECT public: explicit MyWidget(QWidget *parent = 0); ~MyWidget(); private: Ui::MyWidget *ui; WorkThread *thread; public slots: void MyEventHandler1(); void MyEventHandler2(); void GetStr(QString str); };
WorkThread * th = new WorkThread();MyWidget * w = new MyWidget();...QObject::connect(th, SIGNAL( SendStr(QString) ), w, SLOT( GetStr(QString) ));
C++ (Qt)WorkThread * th = new WorkThread();
C++ (Qt)#include <QThread> class WorkThread : public QThread{ Q_OBJECTpublic: explicit WorkThread(QObject *parent = 0); protected: void run(); signals: void SendStr(const QString str); public slots: };