Qt5WebEngineWidgets in Qt app

Hello, I try to create a Flatpak package for my application

Here is what I did so far

flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user org.kde.Sdk
(I use 5.15-21.08)
mkdir app repo

Then, I create a manifest in org.flatpak.myqtapp.json with this content

{
    "app-id": "org.flatpak.myQtApp",
    "runtime": "org.kde.Platform",
    "runtime-version": "5.15-21.08",
    "sdk": "org.kde.Sdk",
    "command": "myqtapp",
    "finish-args": [
        "--share=ipc",
        "--socket=x11",
        "--socket=wayland",
        "--filesystem=host",
        "--device=dri"
    ],
    "modules": [
        {
            "name": "myApp",
            "buildsystem": "cmake-ninja",
            "config-opts": ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"],
            "sources": [
                {
                    "type": "dir",
                    "path": "../"
                }
            ]
        }
    ]
}

then I try to create the Flatpak using

flatpak-builder --user --ccache --repo=repo --force-clean app org.flatpak.myqtapp.json

But I get a basic error:

Emptying app dir 'app'
Downloading sources
Starting build of org.flatpak.myqtapp
Cache miss, checking out last cache hit
========================================================================
Building module myapp in $HOME/myqtapp/flatpak/.flatpak-builder/build/myqtapp-1
========================================================================
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /run/ccache/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):
  Could not find a package configuration file provided by
  "Qt5WebEngineWidgets" with any of the following names:

    Qt5WebEngineWidgetsConfig.cmake
    qt5webenginewidgets-config.cmake

  Add the installation prefix of "Qt5WebEngineWidgets" to CMAKE_PREFIX_PATH
  or set "Qt5WebEngineWidgets_DIR" to a directory containing one of the above
  files.  If "Qt5WebEngineWidgets" provides a separate development package or
  SDK, be sure it has been installed.
Call Stack (most recent call first):
  src/CMakeLists.txt:14 (find_package)


-- Configuring incomplete, errors occurred!
See also "/run/build/myapp/CMakeFiles/CMakeOutput.log".
Error: module myqtapp: Le processus fils s’est terminé avec le code 1

Note that cmake has no problem to find Qt5WebEngineWidgets when I cmake/compile myqtapp in the classical way (withtout Flatpak).

I use Ubuntu 22.04 and official Qt5 Ubuntu packages.

Do you know how to solve that?

No, you don’t use the “official Qt5 Ubuntu packages.”
You are building with the Flatpak KDE SDK.

For QtWebEngine, use the QtWebEngine base app. https://github.com/flathub/io.qt.qtwebengine.BaseApp

Indeed, with io.qt.qtwebengine.BaseApp , it works. It’s weird that it is not included in Flatpak KDE SDK.
Anyway, thank you.