• 6858阅读
  • 3回复

[求职]setUpdatesEnabled设置false和true之间播放视频,出现闪烁 [复制链接]

上一主题 下一主题
离线shayk
 
只看楼主 倒序阅读 楼主  发表于: 2012-10-23
程序流程:
我使用了2个线程,主线程中进行初始化,发送signalEnableUpdate(false)的信号,然后加载主页面;  
子线程里面先是延时等待初始化结束,然后播放一段视频,停止播放后,加载一个子页面,最后发送signalEnableUpdate(true)信号。
信号与槽的定义与连接如下:
connect(this, SIGNAL(signalEnableUpdate(bool)), this,SLOT(slotEnableUpdate(bool)));
void WebBrowser::slotEnableUpdate(bool ok)
{    
    setUpdatesEnabled(ok);
    repaint();
}
现象:问题就是视频停止后,会显示不到1s的主页面,然后才跳转到子页面。(就是这个闪烁问题)
验证:1,如果将发送signalEnableUpdate(true)信号放在加载子页面前面,不会出现闪烁。
          2,如果在加载完子页面后延时一段时间,再发送signalEnableUpdate(true)信号,也不会出现闪烁。
          3,另外,如果在中间不播放视频,也不会出现这种闪烁的情况!
希望大家能帮我找到出现闪烁的原因!!!十分感谢!
离线ggkuroky
只看该作者 1楼 发表于: 2012-10-23
updatesEnabled : bool
This property holds whether updates are enabled.
An updates enabled widget receives paint events and has a system background; a disabled widget does not. This also implies that calling update() and repaint() has no effect if updates are disabled.
By default, this property is true.
setUpdatesEnabled() is normally used to disable updates for a short period of time, for instance to avoid screen flicker during large changes. In Qt, widgets normally do not generate screen flicker, but on X11 the server might erase regions on the screen when widgets get hidden before they can be replaced by other widgets. Disabling updates solves this.
Example:
setUpdatesEnabled(false);
bigVisualChanges();
setUpdatesEnabled(true);
Disabling a widget implicitly disables all its children. Enabling a widget enables all child widgets except top-level widgets or those that have been explicitly disabled. Re-enabling updates implicitly calls update() on the widget.

我只能帮你这么多了,为什么不自己看Qt的帮助文档呢
多么好的教材呀,几乎所有的问题都可以在那里面找到答案,英文慢慢也会变好的!
相信自己,天道酬勤!
离线shayk
只看该作者 2楼 发表于: 2012-10-23
结贴!!!!!自己找到原因了!谢谢楼上的帅哥!
离线shayk
只看该作者 3楼 发表于: 2012-10-23
不是因为setUpdatesEnabled他本身,而是由于其他地方调用了qwebview的load函数
快速回复
限100 字节
 
上一个 下一个