查看完整版本: [-- 111 --]

QTCN开发网 -> Qt 作品展 -> 111 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

rekols 2017-10-29 16:19

111

1111

rekols 2017-10-29 16:20
这种方法比起来更省资源

liuchangyin 2017-10-29 17:05

liudianwu 2017-10-29 19:52
用 repaint();很容易引起崩溃的,尤其是频繁刷新界面的情况下,基本上不建议用 repaint();,建议用update();

rekols 2017-10-29 20:01
liudianwu:用 repaint();很容易引起崩溃的,尤其是频繁刷新界面的情况下,基本上不建议用 repaint();,建议用update(); (2017-10-29 19:52) 

谢谢指导

九重水 2017-10-29 21:14
  

msccreater 2017-10-30 09:54
我比较在意楼主用的什么系统?感觉很好看

rekols 2017-10-30 10:01
msccreater:我比较在意楼主用的什么系统?感觉很好看 (2017-10-30 09:54) 

deepin.org

stlcours 2017-10-30 16:30
liudianwu:用 repaint();很容易引起崩溃的,尤其是频繁刷新界面的情况下,基本上不建议用 repaint();,建议用update(); (2017-10-29 19:52) 

原理是啥?照理说,update是直接调用刷新函数,太忙的时候,才容易崩溃。为什么反而是repaint有这个问题?

liudianwu 2017-10-30 17:12
stlcours:原理是啥?照理说,update是直接调用刷新函数,太忙的时候,才容易崩溃。为什么反而是repaint有这个问题? (2017-10-30 16:30) 

repaint是强制刷新,不管死活的,update是放入事件队列,让qt事件机制去处理。repaint频率过高很容易崩掉的。可自行看qt帮助文档!

stlcours 2017-10-30 19:24
liudianwu:repaint是强制刷新,不管死活的,update是放入事件队列,让qt事件机制去处理。repaint频率过高很容易崩掉的。可自行看qt帮助文档! (2017-10-30 17:12) 

看了,与你说的正好相反:

void QWidget::repaint()

Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden.

We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits Qt to optimize for speed and minimize flicker.

Warning: If you call repaint() in a function which may itself be called from paintEvent(), you may get infinite recursion. The update() function never causes recursion.

http://doc.qt.io/qt-5/qwidget.html#repaint

liudianwu 2017-10-30 21:39
stlcours:
看了,与你说的正好相反:
void QWidget::repaint()
.......

你啥英文水平?能不能有点常识!你看过Qt内部控件的源码么?
[attachment=18079]

hehui 2017-11-01 19:12
stlcours:看了,与你说的正好相反:
void QWidget::repaint()
....... (2017-10-30 19:24) 

如无必要不要用repaint,用update!!!!!!!!!
repaint会强制更新,而update用了事件队列有优化,会忽略一些不必要的更新操作!

rekols 2017-11-02 16:35
hehui:如无必要不要用repaint,用update!!!!!!!!!
repaint会强制更新,而update用了事件队列有优化,会忽略一些不必要的更新操作! (2017-11-01 19:12) 

谢谢你们两的提醒。

hunterzf 2017-11-05 11:31
不错,还能用,谢谢

music010 2018-02-09 11:04
优秀文章,支持!n神马都是浮云

q小玩家 2018-03-03 16:53
          

sunnyhyh 2019-07-22 18:26
图标加上比较贴切。。。


查看完整版本: [-- 111 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled