|
继承而来的子类,在该类中除了定义有关的变量和线程控制函数外,最主要的是定义线程的启动函数UserThread::run(),在该函数中创建了一个用户自定义事件UserEvent,并利用QThread类的postEvent函数提交该事件给相应的接收对象。
class UserThread : public QThread //用户定义的线程类
{
public:
UserThread(QObject *r, QMutex *m, QWaitCondition *c);
QObject *receiver;
}
void UserThread::run() //线程类启动函数,在该函数中创建了一个用户自定义事件
{UserEvent *re = new UserEvent(resultstring);
QThread::postEvent(receiver, re); 页码:[1] [2] [3] [4] [5] [6] 第3页、共6页 |