开发者

QWidget not updating/repainting consistently

I'm building a CAD-like application, when the viewport object selection changes a signal is emitted containing a QHash of the new objects. This signal is caught by it's document sub window which lifts the new properties/settings UI out of them, destroys the existing properties display in the main window properties pane, and replaces them with the new properties/settings.

Using print statements, I know that this works - all the signal/slot connections are firing correctly. However, the properties widgets are very inconsistently repainted, if I perform an operation on the main window directly (press a button, hover the mouse over a widget) the widgets in question update. But when I'm just selecting objects in the viewport, the properties pane 'misses' an update so it ends up displaying the previous object's properties - I know this is not a problem on my end because if I move the window or interact with the widge开发者_Python百科ts (to trigger a repaint), the widgets magically become correct.

These functions are not being called from separate threads. If I manually call update() in my code, nothing changes. If I call repaint() directly (I know I shouldn't) it works a little better, but it's a bit unstable - sometimes the widgets are not drawn at all.

Has anyone had a similar experience?


Have you tried using the static function QApplication::processEvents()?

You may want to do QApplication::processEvents( QEventLoop::ExcludeUserInputEvents ), this prevents the application from handling a mouse click or key press before processEvents returns to the caller.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜