GithubHelp home page GithubHelp logo

seanchas116 / qtimgui Goto Github PK

View Code? Open in Web Editor NEW
345.0 19.0 88.0 102 KB

Qt (QOpenGLWidget / QOpenGLWindow) backend for ImGui

License: MIT License

C++ 89.64% QMake 1.80% CMake 8.56%
qt imgui opengl cpp

qtimgui's Introduction

QtImGui

Qt (QOpenGLWidget / QOpenGLWindow) backend for ImGui

It enables ImGui to run in QOpenGLWidget / QOpenGLWindow.

https://gyazo.com/eb68699c96b9147cca3d5ea9fadfc263

How to use

  • Add QtImGui sources and headers to your project
    • If you are using git submodule, run git submodule update --init --recursive to ensure that the inner submodule is initialized as well.
  • CMake:
    • Add add_subdirectory(path/to/qtimgui) to your CMakeLists.txt file
    • Link qt_imgui_quick (for Qt Quick apps or apps that don't use QOpenGLWidget) or qt_imgui_widget (for apps using QOpenGLWidget)
  • qmake:
    • Add include(path/to/qtimgui/qtimgui.pri) to your .pro file
  • Subclass QOpenGLWindow or QOpenGLWidget and:
class DemoWindow : public QOpenGLWindow
{
protected:
    void initializeGL() override
    {
        QtImGui::initialize(this);
    }
    void paintGL() override
    {
        // you can do custom GL rendering as well in paintGL

        QtImGui::newFrame();

        ImGui::Text("Hello");
        // more widgets...

        ImGui::Render();
        QtImGui::render();
    }
};

See QOpenGLWidget example and QOpenGLWindow example for details.

Specific notes for Android, when using cmake

Two projects are provided: qtimgui.pro and CMakeLists.txt.

When using CMake under Android, this project will uses qt-android-cmake, which is a CMake utility for building and deploying Qt based applications on Android without Qt Creator.

In order to successfuly deploy the app to a device, the cmake variable ANDROID_NATIVE_API_LEVEL should elevated to 21 or 26 (depending on the native levels installed in your android sdk) You will need to set it via the CMake command line, or inside Qt Creator (in the project view).

qtimgui's People

Contributors

crolando avatar dimateos avatar fghoussen avatar inobelar avatar pthom avatar redwork321 avatar seanchas116 avatar xaekai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtimgui's Issues

Mac os display error!

截屏2024-05-03 上午12 41 56

on Mac os. the contents on the window don't display normally. It display only when I drag the window to the top left corner of the big main window.

not showing imgui

I compiled and run your project, but a main window shown up, no imgui window, could you tell me what's wrong? I used visual studio 2015 to convert you .pro project to a vs project with qt-vs-tools-msvc2015-2.1.1, with Qt5.8 enviroment. thank you.

i actually hope this Dear ImGui can work under Qt4.86 (since one of my project is constructed under this). is it possible? thank you .

winston

IME seems not support in inputtext

Input Method Editors can't use in inputtext,but it's ok in gltf backend on windows.

I find the code in glfw backend ,need add something like this:

  #if defined(_WIN32)
      ImGui::GetMainViewport()->PlatformHandleRaw = (void*)glfwGetWin32Window(bd->Window);
  #endif

Using QtImGui with multiple QOpenGLWidgets?

Is it possible to use QtImGui with multiple QOpenGLWidgets sharing the same class? I'm calling QtImGui functions while QOpenGLWidget is underMouse() which prevents crashing but ImGui does not render in the other active viewports, only the first one.

backend using io.KeyMap[], io.KeysDown[] should call io.AddKeyEvent() instaed

[Problem]
According to imgui release v1.87 :
2022/02/29: We discovered a backward-compatibility regression in 18700:
Direct legacy reads from io.KeysDown[] won't work with new backends.
And in particular io.KeysDown[GetKeyIndex[XXX]) will buffer overflow in old and new backends.
You can refer to https://github.com/ocornut/imgui/issues/4921
[Solution]
Backend writing to io.KeyMap[], io.KeysDown[] -> backend should call io.AddKeyEvent()

Demo crash when using ImGui branch docking

Describe the bug
Switch ImGui branch to docking branch then run demo, demo crashed, print assert meesage:

Assertion failed: (g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < ((int)(sizeof(g.IO.KeysDown) / sizeof(*(g.IO.KeysDown)))) && "io.KeyMap[] contains an out of bound value (need to be 0..511, or -1 for unmapped key)"), function ErrorCheckNewFrameSanityChecks, file imgui.cpp, line 8557.

Using master ImGui branch is ok, even I check out a new branch from docking and merge master, it also crashed, could you give me some help? Thank you.

No rule to make target

No rule to make target '../../qtimgui-master/imgui/imgui_draw.cpp', needed by 'debug/imgui_draw.o'. Stop.

BUG: incorrect background for pop up modals

Describe the bug
Incorrect background color for modal windows.

Note that I am using imgui 1.89.2.WIP with docking plus some fixes for the keyboard from #44

To Reproduce
Just open the modal popup window as shown in the screenshot.

Screenshots
image

Expected
image

I already got it working so will post a PR 😃 solving this specifically, no other changes

BUG: Mouse pos being updated when other widget has focus

Describe the bug

Currently the imgui mouse pos is updated whenever the widget window/window is active. But in the case of widgets windows it also makes sense to check the focus. Otherwise a mouse over the area can trigger hovering effects in imgui when the user is interacting with other QT widgets.

viewer_WzmmTVZ1Y9

//... ImGuiRenderer.cpp
if (m_window->isActive()) // + also check focus in case of widget
{
    const QPoint pos = m_window->mapFromGlobal(QCursor::pos());
    io.MousePos = ImVec2(pos.x(), pos.y());
}
else
{
    io.MousePos = ImVec2(-1,-1);
}

To Reproduce
Have any widget like a combo box that expands over the widgets area when interacted.

Expected behavior
Imgui mouse pos should not be updated when the widget has no focus other widget has focus to avoid hovering triggers.

viewer_mlYkJNG894

Desktop (please complete the following information):

  • OS: Win10. Note that I am using imgui 1.89.2.WIP with docking plus some fixes for the keyboard, etc.

QT not forwarding "double mouse click" events

I'm on windows 10.
A lot of the button widgets don't respond to rapid left-clicks.

I found a bug in the event filter that blocks the QEvent::MouseButtonDblClick events from progressing to imgui.

If I add this to the eventFilter switch statement, the double click events are passed to imgui, and the buttons then respond to rapid left clicks.

You can test this by checking the demo "double click" debug field to make sure the events are getting to imgui. See below for source code change location, and test location.

demo_location
fix_line

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.