ChatGPT解决这个技术问题 Extra ChatGPT

项目错误:QT 中的未知模块:webkitwidgets

我正在将代码从 qt4 移植到 qt5。我将以下行添加到我的 .pro 文件 as suggested

QT += webkitwidgets

但是,当我运行 qmake 时,我得到了这个错误:

Project ERROR: Unknown module(s) in QT: webkitwidgets

我正在 Ubuntu 12.04 LTS 上开发并安装了 Qt as described

如何在 macOS 中解决此问题 - stackoverflow.com/questions/72589559/…

u
user1251007

您需要安装 webkitwidgets 库。

在 Ubuntu 上,在终端中尝试:

sudo apt-get install libqt5webkit5-dev

在 Fedora 上,包有不同的名称,因此尝试:

sudo apt-get install qt5-qtwebkit-devel

或者在 Fedora 上,通过 dnf:

sudo dnf install qt5-qtwebkit-devel

OS X 有什么解决方案吗?
嘿,我试过了,但它仍然抛出同样的错误。有解决办法吗?
窗户呢?
@Muadh Programmer:这个问题表明需要一个针对 Ubuntu 的解决方案,所以我的答案是针对那个操作系统。但是,其他答案针对 Windows。如果您对他们的解决方案有疑问,可以评论他们的答案。
如何在 macOS 中解决此问题 - stackoverflow.com/questions/72589559/…
A
Alex

如果您需要为 Qt 5.7 安装 webkit* Windows 库,您应该手动编译它,因为在新版本中 webkit (WebView?) 被 WebEngine 取代。

了解 Qt 5.7 版本(评论):http://blog.qt.io/blog/2016/06/16/qt-5-7-released/

构建顺序(静态或共享):

1) 下载 Qt 5.7.0 源:http://download.qt.io/community_releases/5.7/5.7.0/

2)下载所需工具:ActiveState Perl(二进制)、Python(二进制)、Ruby(二进制)、GnuWin Bison(二进制)、GPref(二进制)、Grep(二进制)、WinFlex、LibIconv、make(二进制)、sqlite(源码!), ICU (source), windows msys (binary) (unix like shell with the tools), mingw-w64 (bin+dev) for build Qt with QtWebKit, see link on: https://trac.webkit.org/wiki/BuildingQtOnWindows

3) 将 ICU 源码下载到 C:\icu\icu 后。通过打开开始窗口菜单(应下载并安装 msys)打开 msys QT mingw 控制台外壳并搜索或使用快速搜索。在打开的控制台中启动配置脚本,然后编译并安装:

$ cd C:\icu\icu\source $ ./runConfigureICU $ set PATH=%PATH%;C:\msys\1.0\bin\ $ make.exe $ make.exe install

4)使用(!)ICU支持构建Qt(设置“-icu”进行配置)参见下面的编译脚本。将 PATH 更改为您的环境。

目录结构:

C:\Qt\5.7.0 - 在此处下载 Qt 5.7.0 的二进制版本

C:\Qt\5.7.0n - 5.7.0 的新(编译)版本的目录(只需制作目录)

C:\Qt\Src - 在此处下载 Qt 5.7.0 的源代码

C:\Qt\Src\qtbase\compile.bat

set INCLUDE=C:\icu\icu\dist\include
set LIB=C:\icu\icu\dist\lib
set QTDIR=C:\Qt\5.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0\5.7\mingw53_32\bin;C:\Qt\Qt5.7.0\Tools\QtCreator\bin;C:\Qt\Qt5.7.0\Tools\mingw530_32\bin;C:\Qt\Src\qtbase\bin;C:\Program Files (X86)\GnuWin32\bin;C:\winflex;C:\Ruby23-x64\bin;C:\Python27;C:\mingw-w64\i686-1\mingw32\bin;C:\icu\bin
set QMAKESPEC=win32-g++
set BUILD_DIR=C:\Qt\Qt5.7.0n
call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -no-compile-examples -icu -I C:/icu/icu/dist/include -L C:/icu/icu/dist/lib
jom.exe -j 4
pause

在 Windows Power Shell 中以示例运行命令:

$ cd C:\Qt\Src\qtbase $ ./compile.bat

通过编译后使用它来安装BUILD_DIR中的文件(安装Qt文件):

$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe 安装

Qt 应该开始安装

5) 将 Qtwebkit 源下载到 C:\Qt\Src\qtwebkit。使用下面的编译脚本来编译 qtwebkit,使用新的 Qt 5.7.0 构建,文件位于 C:\Qt\5.7.0n 和 ICU。

C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat

set INCLUDE=C:\sqlite
set LIBS=C:\sqlite
set SQLITE3SRCDIR=C:\sqlite
set QTDIR=C:\Qt\Qt5.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0n\bin;C:\Qt\Src\qtbase\bin;C:\winflex;C:\Ruby23-x64\bin;C:\Python27;C:\mingw-w64\i686-1\mingw32\bin;C:\icu\bin;C:\Program Files (x86)\GnuWin32\bin
set QMAKESPEC=win32-g++
call perl.exe .\build-webkit --qt --release

编译 qtwebkit:

$ cd C:\Qt\Src\qtwebkit\Tools\Scripts $ ./compile.bat $ cd C:\Qt\Src\qtwebkit\WebKitBuild\Release $ C:\mingw-w64\i686-1\mingw32\bin\ mingw32-make.exe 安装

成功编译和安装后,应该可以使用 qtwebkit 编译您的应用程序。

为静态构建 QT

编辑文件 C:\Qt\Src\qtbase\compile.bat 并通过构建。

...
call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -static -no-compile-examples -icu
echo "QMAKE_FLAGS += -static -static-libgcc" >> .mkspecs/%QMAKESPEC%/qmake.conf
...

可能的错误

1) 在构建 qtwebkit 时:"fatal error: unicode/uchar.h: No such file or directory"

检查您的 Qt 5.7.0n 是否使用 ICU 构建。 IT 还可以在 qtwebkit 的配置中通知您“需要 ICU”。

2) flex: unknown flag '-'. For usage, try

在这种情况下,您应该使用正确版本的 Flex,即“win_flex”。您应该重命名文件以使用 win_flex 而不仅仅是 flex(和 bison)。

1) 将 C:\Program Files (x86)\GnuWin32\bin\flex.exe 重命名为一些未使用的名称。 2) 将 C:\Program Files (x86)\GnuWin32\bin\bison.exe 重命名为一些未使用的名称。 3) 将 C:\winflex\win_bison.exe 重命名为 bison.exe。

3) 构建 qtwebkit 时:"fatal error: sqlite3.h: No such file or directory"

编辑文件 C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat 并检查 sqlite 的正确路径:

set SQLITE3SRCDIR=C:\(path to some SQLITE .h/source files)

4) skipping incompatible ... when searching for ...

您应该下载正确的库拱门(32 位或 64 位)

5) View.cpp ... undefined reference to WKPageCanGoBack

通过某些测试或 MiniBrowser 时可能会发生。您可以在文件中搜索“UIProcess/API/qt”和“MiniBroswer”并将其从 Makefile 和其他一些文件中删除,然后重新开始构建。

链接

构建 Qt5:https://wiki.qt.io/Building_Qt_5_from_Git Qt WebKit 构建方法如下:https://trac.webkit.org/wiki/BuildingQtOnWindows 使用 GNU 构建 ICU:https://wiki.qt.io/Compiling -ICU-with-MinGW


你好,我被困在 C:\Qt\Src\qtbase\compile.bat 这失败了“C:\qt5.7-source\qtbase>jom.exe -j 4 错误:文件 Makefile 不存在。”你知道可能是什么问题吗?
app developer 27,确保 bat 文件中的上一条命令成功完成:“call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-发布 -opensource -opengl 桌面 -no-compile-examples -icu -IC:/icu/icu/dist/include -LC:/icu/icu/dist/lib"
谢谢您的回答!现在我认为使用 qtbase\compile.bat 更进一步。您知道什么可能导致最新的错误“命令的语法不正确。”吗? pastebin.com/pCLXvs22
app developer 27,可能make版本和mingw ot Visual Studio版本不一样,你用什么编译?检查您的 make 二进制文件以获取项目路径并确保它是正确的。
我从来没有让它工作。但最终找到了这个github.com/annulen/webkit/releases/tag/qtwebkit-tp5,我可以使用它来使用更新的 webkit 和 qt 5.8。
N
Nightingale7

Alex 引用的社区构建仅在 Qt 5.9 之前可用。如果你想使用更新的 Qt5(当前版本是 5.11),那么另一个选择是将“QtWebKit”移植到“QtWebEngine”。

请参阅:https://wiki.qt.io/QtWebEngine/Porting_from_QtWebKit


如何在 macOS 中解决此问题 - stackoverflow.com/questions/72589559/…
J
JDavis

我通过从以前的安装 5.5 复制 webkit 和 webkitwidgets pri 文件来让它工作。

~/Qt/5.5/clang_64/mkspecs/modules/


t
tonisives

对于 Windows,我刚刚下载了 https://github.com/annulen/webkit/releases/tag/qtwebkit-tp5 并将文件夹复制到相关的 Qt 安装文件夹。现在我可以将 MinGW Qt5.8 与最新的 webkit 一起使用。感谢康斯坦丁和这个项目的所有贡献者!

只有一件事需要注意——我需要使用 Qt 中的发布配置。


你能说出你粘贴这些文件的相关文件夹吗?
T
The Dnino

对我有用的是两个答案的组合,我使用了@user1251007 建议的+这个命令

sudo apt-get install libqt5websockets5-dev

在此处找到此命令行:link to the stackoverflow response


关注公众号,不定期副业成功案例分享
关注公众号

不定期副业成功案例分享

领先一步获取最新的外包任务吗?

立即订阅