QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1791|回复: 2

qt中postEvent()为什么会丢失?

[复制链接]
发表于 2004-9-29 19:52:27 | 显示全部楼层 |阅读模式
我在一个线程中接受网络传过来的包,然后用Application::postEvent()通知
主线程(负责GUI)更新。
  可是发现有些QEvent没有发到接受者那里(表现为gui更新漏信息)。可是我
计算了一下postEvent的频率不高,才几hz亚。
  查了google,说异步线程不用postEvent还不行,昏亚~。
  那位大虾帮我分析一下有什么地反考虑不周到!
  bow!
发表于 2004-9-30 14:50:30 | 显示全部楼层
$QTDIR/doc/html/eventsandfilters.html

sendEvent() processes the event immediately - when sendEvent() returns, (the event filters and) the object have already processed the event. For many event classes there is a function called isAccepted() that tells you whether the event was accepted or rejected by the last handler that was called.

postEvent() posts the event on a queue for later dispatch. The next time Qt's main event loop runs, it dispatches all posted events, with some optimization. For example, if there are several resize events, they are are compacted into one. The same applies to paint events: QWidget::update() calls postEvent(), which minimizes flickering and increases speed by avoiding multiple repaints.
回复

使用道具 举报

 楼主| 发表于 2004-10-1 18:44:18 | 显示全部楼层
可是sendEvent()不能用多线程亚。
postEvent()可以亚。
怎么办亚。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-7 09:28 , Processed in 0.086079 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表