Skip to content

CrimsonAS/imgui-qtquick

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Integration of Dear ImGui with Qt Quick

There are multiple ways to do this. Here we chose to expose a QQuickItem backed by a QSGRenderNode (that issues the draw calls directly, no intermediate render target; both threaded and basic render loops should work).

Alternatives would be to do it overlay-style connected to QQuickWindow::afterRendering() or to construct scenegraph nodes (a geometry node for each ImDrawCmd, clip nodes, etc.), each coming with its own pros and cons.

By having a true Quick item, the ImGui "desktop"'s position, size, stacking, opacity, etc. is fully under the application's control and can be controlled via the usual QML means, while the frame generation can be hooked onto a convenient signal. Note that this will not allow arbitrary transformations on the item, apart from translation (scale should be fixed at some point though. the rest just won't work.)

import QtQuick 2.0
import ImGui 1.0

Rectangle {
    id: root

    ...

    ImGui {
        objectName: "imgui"
        anchors.fill: parent
        focus: true
    }
}

int main(int argc, char *argv[])
{
    ...

    QQuickView viewer;
    viewer.setSource(QUrl("qrc:/main.qml"));

    ImGuiItem *imguiItem = viewer.rootObject()->findChild<ImGuiItem *>("imgui");
    QObject::connect(imguiItem, &ImGuiItem::frame, imguiItem, [] {
        ImGui::Text("Hello, world!");
    });

    ...

About

Qt Quick integration for Dear ImGui

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 82.9%
  • QML 14.9%
  • QMake 2.2%