seanchas116 / qtimgui

Qt (QOpenGLWidget / QOpenGLWindow) backend for ImGui
MIT License
375 stars 96 forks source link

Qt imgui runner #17

Closed pthom closed 4 years ago

pthom commented 4 years ago

Hello,

This PR adds QtImGuiRunner, which enables to write an app with very few lines of code, by simply registering a gui loop function or lambda.

You can then write a destkop / mobile app in very few lines of code:

include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/qtimgui_android.cmake)
add_imgui_app(demo_runner_minimal demo-runner-minimal.cpp)
#include <QtImGuiRunner.h>
int main() {
    int answer = 42
    auto gui_loop = [&]() { ImGui::InputInt("Your answer", &answer);  };
    QtImGuiRunner::Run(gui_loop, {"qtimgui minimal demo", 300, 90});
}

I am a lazy guy, so that it makes me happy to be able to quickly produce and test a new app without having to worry about configuring cmake, qt, etc :-)

I added some doc and a demo about it in the readme

The demo is like this: aa

What do you think?

pthom commented 4 years ago

I tested it successfully on mac and linux

seanchas116 commented 4 years ago

It's nice! But it might be a little out of scope of this project so keeping it a separate repo might be better.

pthom commented 4 years ago

Ok, your choice. I liked the possibility to run start a new app from scratch with so few lines. Anyhow, may be I'll do another repo later.

I will add another PR that includes only the update to qt-android-cmake.