Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [DirectX] Window doesn't update unless i move it

[DirectX] Window doesn't update unless i move it

Scheduled Pinned Locked Moved Game Development
directxupdatedebugging
3 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kieran
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      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 call update() or repaint() (read the docs for difference!) from a timer event. The former will schedule a paint event and the latter will force the repaint immediately.

      K 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        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 call update() or repaint() (read the docs for difference!) from a timer event. The former will schedule a paint event and the latter will force the repaint immediately.

        K Offline
        K Offline
        Kieran
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved