|
idget::customEvent(QCustomEvent *e) //用户自定义事件处理函数
{ if (e->type()==346798)
{
UserEvent *re = (UserEvent *) e;
newstring = re->str();
}
}
在这个例子中,UserWidget对象中创建了新的线程UserThread,用户可以利用这个线程实现一些周期性的处理(如接收底层发来的消息等),一旦满足特定条件就提交一个用户自定义的事件,当UserWidget对象收到该事件时,可以按需求做出相应的处理,而一般情况下,UserWidget对象可以正常地执行某些例行处理,而完全不受底层消息的影响。
页码:[1] [2] [3] [4] [5] [6] 第5页、共6页 |