Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using QT as a UI for game rendered with DirectX
QtWS25 Last Chance

Using QT as a UI for game rendered with DirectX

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.1k 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.
  • C Offline
    C Offline
    Cynical
    wrote on last edited by
    #1

    Hi, I'm developing a game in a framework which uses DirectX for rendering and I'm coming to a stage where I want to implement a proper UI. Seeing how I have (some) experience with QT, it seemed like a natural fit.

    Without having delved too deep into the QT source code, would it be possible to render a QApplication (or anything using the QT framework for that matter) inside an application which is not QT, i.e. a game using DirectX? So for example, having a menu screen using QWidgets inside the same executable as the game itself.

    Any help would be much appreciated!

    mrjjM 1 Reply Last reply
    0
    • C Cynical

      Hi, I'm developing a game in a framework which uses DirectX for rendering and I'm coming to a stage where I want to implement a proper UI. Seeing how I have (some) experience with QT, it seemed like a natural fit.

      Without having delved too deep into the QT source code, would it be possible to render a QApplication (or anything using the QT framework for that matter) inside an application which is not QT, i.e. a game using DirectX? So for example, having a menu screen using QWidgets inside the same executable as the game itself.

      Any help would be much appreciated!

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Cynical
      Hi
      Yes, you can have a Qt app that creates a DirectX context for the game part.
      However, Qt need the QApplication object and its event loop running so
      the other way around having a normal Windows message pump and then use Qt is
      more involved but not impossible.
      However, it should be quite possible to use Qt for menu etc but it wont render on top of
      a fullscreen directX surface as far as i know.

      1 Reply Last reply
      1
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        While it's certainly doable I would advise against it. If you already have a framework it's probably gonna be challenging to integrate its event loop with Qt's. Apart from that it's a question of what sort of integration you want. If you want Qt widgets on top of your rendering then you'd have to create Qt's widgets as a separate window on top of yours. This would probably complicate input and focus handling. If you want the widgets "inside" your DirectX scene or in a fullscreen mode you'd have to render the widgets into a pixmap, upload it as DirectX texture and render that in engine. This further complicates input handling, as you would basically have to "fake" Qt events, do coordinates translation, focus handling etc. It could also tank your performance, as the widgets are rendered on the CPU and uploading them as textures would be additional cost.

        All in all I think it's more trouble than it's worth. I would suggest to turn your eye into one of the libraries that are specifically targeted for exactly this kind of task, for example Dear ImGui. It has a lot smaller footprint than Qt, and integrates directly with your engine - i.e. it leverages the rendering and input handling that you already have.

        1 Reply Last reply
        2

        • Login

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