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. CEF(chromium embedded framework) and QT cross-platform integration

CEF(chromium embedded framework) and QT cross-platform integration

Scheduled Pinned Locked Moved General and Desktop
cefqt-mainloop
2 Posts 2 Posters 4.9k 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.
  • N Offline
    N Offline
    neagoegab
    wrote on last edited by neagoegab
    #1

    Hi,

    I'm new on this forum and before posting I've searched the forum for an answer to my questions and found nothing.

    Description:

    I have to integrate CEF(chromium embedded framework) with an existing Qt based cross-platform (Mac and Windows) application. Due to legacy web code, third party web applications integration and automatic proxy authentication I cannot use QtWebKit for this task,

    What have I tried:

    1. To use CEF with multi-threaded-message-loop. While this works on Windows it doesn't work on Mac. Cocoa doesn't allow to have multiple UI threads and all UI related work should be done on the main thread. CEF with multi-threaded-message-loop creates a separate window events handler thread, who manages windows created by CEF.

    2. Custom loop in this way:

        while(g_quit)
        {
            a.processEvents(); //is the same function that is called from the default .exec() application loop
            CefDoMessageLoopWork();
            QThread::msleep(20);
            CefDoMessageLoopWork();
        }
    

    But here I saw several issues. Both CEF and Qt on Windows have the following default loop implementation:

    • PeekMessage with PM_REMOVE, removes the message from the queue

    • TranslateMessage

    • DispatchMessage

    In addition, QT's windows events dispatcher adds the following specific message handling:

    ...

     haveMessage = PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
                    if (haveMessage && (flags & QEventLoop::ExcludeUserInputEvents)
                        && ((msg.message >= WM_KEYFIRST
                             && msg.message <= WM_KEYLAST)
                            || (msg.message >= WM_MOUSEFIRST
                                && msg.message <= WM_MOUSELAST)
                            || msg.message == WM_MOUSEWHEEL
                            || msg.message == WM_MOUSEHWHEEL
                            || msg.message == WM_TOUCH
    #ifndef QT_NO_GESTURES
                            || msg.message == WM_GESTURE
                            || msg.message == WM_GESTURENOTIFY
    #endif
                            || msg.message == WM_CLOSE)) {
    

    ...

                   else if (msg.message == WM_TIMER) {
                        // avoid live-lock by keeping track of the timers we've already sent
                        bool found = false;
                        for (int i = 0; !found && i < processedTimers.count(); ++i) {
                            const MSG processed = processedTimers.constData()[i];
                            found = (processed.wParam == msg.wParam && processed.hwnd == msg.hwnd && processed.lParam == msg.lParam);
                        }
                        if (found)
                            continue;
                        processedTimers.append(msg);
                    } else if (msg.message == WM_QUIT) {
                        if (QCoreApplication::instance())
                            QCoreApplication::instance()->quit();
                        return false;
                    }
    

    If the messages that have special treatment in Qt's windows event dispatcher are dispatched by the CEF's loop, the application looses functionality. I don't know all the QT features that are used by the application to know the effects of removing some of the QT functionality.

    For Mac I've seen that there are Carbon/Cocoa event dispatchers and I don't have the experience to understand if CEF message loop goes hand in hand with Qt's.

    1. Separate CEF process controlled through IPC. The CEF process was supposed to create browser child windows and attach them to the main process windows. On Windows this works because you can attach child windows to another process' windows, but on Mac I was unable to do that using the documented Cocoa APIs.

    I need to know if there is a successful story of integrating CEF with Qt, without source code modification in any of them and without using CEF with window less rendering.

    Any help is appreciated! ;)

    Thank you,
    Gabriel

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tishion
      wrote on last edited by
      #2

      you can look into this project.
      https://cefview.github.io/QCefView/

      This project was born in 2016.

      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