C++ (Qt)class MyThread : public QThread{Q_OBJECT public: explicit MyThread( QObject *parent = 0 ); virtual ~MyThread(); protected: virtual void run();};
C++ (Qt)MyThread::MyThread( QObject *parent ) : QThread(parent){ moveToThread( this );}void MyThread::run(){ int argc = 0; QApplication app(argc, 0); m_pSocketListener = new QUdpSocket(); m_pSocketListener->moveToThread( this ); m_pSocketSender = new QUdpSocket(); m_pSocketSender->moveToThread( this ); app.exec();}
C++ (Qt)void MyThread::run(){ int argc = 0; QApplication app(argc, 0); m_pSocketListener = new QUdpSocket(); m_pSocketListener->moveToThread( this ); m_pSocketSender = new QUdpSocket(); m_pSocketSender->moveToThread( this ); app.exec();}
C++ (Qt)MyThread::MyThread( QObject *parent ) : QThread(parent){ moveToThread( this );} void MyThread::run(){ int argc = 0; QApplication app(argc, 0); m_pSocketListener = new QUdpSocket(this);.... m_pSocketSender = new QUdpSocket(this); .... exec(); }