Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Flutter integration with Qt

Flutter integration with Qt

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
2 Posts 2 Posters 467 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.
  • S Offline
    S Offline
    slandino
    wrote on 28 Nov 2024, 18:29 last edited by
    #1

    Hi, I have an existing application on C++ with Qt and I wanna extend it by using Flutter. I have tried to use https://github.com/flutter/engine/tree/main/shell/platform/embedder. Currently I am trying to configure engine via FlutterRendererConfig but looks like I should use low level rendering primitives like QOpenGLContext. I have faced an issue with it, because QOpenGLContext cannot be used outside of the thread where it was created. But I need to use it for configuring Flutter engine (code snippet below).

    FlutterRendererConfig config = {};
         config.type = kOpenGL;
         config.open_gl.struct_size = sizeof(config.open_gl);
         config.open_gl.make_current = [](void *userdata) -> bool {
             QOpenGLContext *context = static_cast<QOpenGLContext *>(userdata);
             return context->makeCurrent(static_cast<QWindow *>(context->surface()));
         };
         config.open_gl.clear_current = [](void *) -> bool {
             QOpenGLContext::currentContext()->doneCurrent();
             return true;
         };
         config.open_gl.present = [](void *userdata) -> bool {
             QOpenGLContext *context = static_cast<QOpenGLContext *>(userdata);
             context->swapBuffers(static_cast<QWindow *>(context->surface()));
             return true;
         };
    

    Maybe somebody have done this before and could share a small code snippet with correct configuration? Or there are some ideas how to fix QOpenGLContext limitation?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alessandro M
      wrote on 10 Dec 2024, 19:55 last edited by
      #2

      Hi Slandino, I started working a few days ago on a project to mix Qt and flutter. I have already some working code, but it's using offscreen buffers (my final objective is to make a plugin to have a flutter layer in OBS) so I've not even looked on how to render to a window context. But the code may still work for you. I've commited the mess of code I wrote so far to https://github.com/hefsoftware/temp_qt_flutter (it compiles on windows, at least for me). Hope it will give you some help.

      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