[DirectX] Window doesn't update unless i move it
-
Okay so while i was on holiday i was working on my laptop and i decided to make the move from Win32 API to Qt and everything was working fine. Until i got back on my PC, that is. This problem only occurs on my PC and not on my laptop i have use win merge to try and detect any differences and there are NONE.
The way i have implemented this is i have a QWidget and I've overridden the paintEngine function to do nothing and i set the DirectX HWND to the WId of the game view QWidget.
Any help on this would be greatly appreciated
-
Hi, welcome to devnet.
paintEvent()
is only called "when needed". This means different things on different occasions. Whether or not it is called constantly, on mouse move or only when something changes in it will depend on your OS, windows manager settings (eg. Aero enabled/disabled), graphics drivers etc. Qt tries to keep the number of paint events to minimum as an optimization measure (widgets are mostly static ui).In general you can't anticipate when the window is repainted by OS or Qt, but you can cause it to repaint yourself.
One way is to start a timer and callupdate()
orrepaint()
(read the docs for difference!) from a timer event. The former will schedule a paint event and the latter will force the repaint immediately. -
@Chris-Kawa Hi thanks for your reply. For some reason, though, it has started working again. All i changed was I added QWidget::resizeEvent(pEvent); to the GameView class and it started working. However, here is where it gets weird. when i remove that line it still works, so effectively i have changed nothing and it started working