Mac下如何打包发布使用了QtWebEngine的PyQt5程序?

发布于 2022-09-11 20:46:34 字数 3413 浏览 23 评论 0

先用Pyinstaller打包后生成一个app,然后只有Contents这个目录
打开这个里面是Framework(空)、Info.plist MacOS(空)、 Resources(只有一个图标)
我按照官网的https://doc.qt.io/qt-5/qtwebe...
还是直接崩溃啊
我看了下主要就2个部分:
一个是Deploying Qt WebEngine Processes
原文件QtWebEngineProcess在QtWebEngineCore.Framework的Helpers下面
官网的操作是放到.app/Helpers/QtWebEngineProcess
还有一个是Deploying Resources
这几个文件
qtwebengine_resources.pak contains the resources needed by Chromium.
qtwebengine_devtools_resources.pak contains tools for remote debugging.
qtwebengine_resources_100p.pak contains images suitable for low resolution displays.
qtwebengine_resources_200p.pak contains images suitable for high DPI displays.
icudtl.dat
是在QtWebEngineCore.Framework的Resources下面
拿出来放在.app/Content/Resources (这里为什么是Content,而不是Contents?)
但是还是运行不了

Deploying Libraries
The following libraries must be deployed with applications that depend on Qt WebEngine:

QtWebEngineCore library
QtWebEngineWidgets or QtWebEngine libraries, depending on application type
Deploying QML Imports
If Qt Quick integration is used in the application, the QtWebEngine import directory needs to be deployed.

Deploying Qt WebEngine Processes
Qt WebEngine takes advantage of the multi-process model that the Chromium project offers. The multi-process model requires that the Qt WebEngine Process executable be deployed alongside your application.

The WebEngine process is executed for each QWebEngineView or WebEngineView instance. For example, a browser application with two tabs open should have two separate instances of the process running. This is a common approach used by most modern web engines to provide a stable browsing experience.

At runtime, Qt WebEngine looks for the QtWebEngineProcess executable in the directory that QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath) returns. For Qt installations, this is QTDIR/libexec (Linux) or QTDIR\bin (Windows). The path can be changed by defining a qt.conf file, for example. Alternatively, an executable path can be set as a value of the QTWEBENGINEPROCESS_PATH environment variable. On macOS, Qt WebEngine looks for the executable in .app/Helpers/QtWebEngineProcess.

Deploying Resources
Qt WebEngine requires the following resource files:

qtwebengine_resources.pak contains the resources needed by Chromium.
qtwebengine_devtools_resources.pak contains tools for remote debugging.
qtwebengine_resources_100p.pak contains images suitable for low resolution displays.
qtwebengine_resources_200p.pak contains images suitable for high DPI displays.
icudtl.dat provides support for International Components for Unicode (ICU). It is the Chromium version of ICU, which is not needed if Qt WebEngine was configured to use the system ICU.
Resources are searched from the following locations:

On Linux and Windows: the resources directory in the directory specified by QLibraryInfo::location(QLibraryInfo::DataPath)
On macOS: .app/Content/Resources
Translations
Locale data (such as en-US.pak) is searched form the following locations:

On macOS: .app/Content/Resources
On Linux and Windows: qtwebengine_locales directory in the directory specified by QLibraryInfo::location(QLibraryInfo::TranslationsPath)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文