Build QWebEngineView program under MacOS

If we have a QWebEngineView program like this that needs to be built

QWebEngineView Demo

We execute the following command.

pyinstaller -D $HOME/webengine/webengine.py

After executing the command, we get two directories.

  • build
  • dist

We go to the $HOME/webengine/dist/webengine/ directory,Find the webengine file,This is the entrance to the program. Let’s double-click to run it. But the program did not work as expected and output the following prompt.

Could not find QtWebEngineProcess
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

Don’t worry, let’s access the Qt installation path.

Then we visit the lib directory, find QtWebEngineCore.framework double-click on it. Then we copy the Resources directory and Helpers/QtWebEngineProcess.app to $HOME/webengine/dist/webengine directory. Let’s copy the Resources directory again to the $HOME/webengine/dist/ directory

Finally, we in the $HOME/webengine/dist/webengine now executing the following command.

install_name_tool -change @rpath/QtWebEngineCore.framework/Versions/5/QtWebEngineCore @loader_path/../../../QtWebEngineCore QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtQuick.framework/Versions/5/QtQuick @loader_path/../../../QtQuick QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtQml.framework/Versions/5/QtQml @loader_path/../../../QtQml QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtNetwork.framework/Versions/5/QtNetwork @loader_path/../../../QtNetwork QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore @loader_path/../../../QtCore QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtGui.framework/Versions/5/QtGui @loader_path/../../../QtGui QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtWebChannel.framework/Versions/5/QtWebChannel @loader_path/../../../QtWebChannel QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
install_name_tool -change @rpath/QtPositioning.framework/Versions/5/QtPositioning @loader_path/../../../QtPositioning QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess

Now, let’s double-click the webengine program to work.