开发者

Reducing flicker with QBoxLayout

Whenever a displayed QBoxLayout is populated, there's some flicker on the screen as widgets get added to the layout. How do I stop this flicker?

setUpdatesEnabled did not do 开发者_如何转开发the trick.


show() the widget only after you've finished populating it/laying it out.

Or don't attach your layout to it's widget before you're done adding things to it. (i.e. only call setLayout(your_layout) when you've finished adding things to your_layout).

Alternatively, look into the updatesEnabled QWidget property. You can use that to temporarily disable the widget's updates to prevent flicker. (This is most useful on the more complex widgets like QTableWidget and similar when you are making "massive" changes to the underlying data.)

Quote from the doc above:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜