编译提示:QWebFrame: QWebFrame: No such file or directory
如果在QTcreator里面添加头文件
#include <QWebView>
#include <QWebFrame>
#include <QWebView>
提示没有文件或目录
说明qt库没有完全安装,确切的说是缺少WebKit这个库,webkit里面包含这三个类。
进入qt的安装目录/usr/local/Trolltech/Qt-4.8.6/include(默认安装路径)发现确实没有QtWebKit文件,说明在编译安装qt源码的时候没有编译webkit模块
1、进入qt源码目录重新编译安装qt
./configure
注意看终端打印的信息,过一会有如下显示
Warning: -no-xrender will disable the QtWebkit module.
在下面的配置信息里面有
Qt 3 compatibility ..... yes
QtDBus module .......... yes (run-time)
QtConcurrent code ...... yes
QtGui module ........... yes
QtScript module ........ yes
QtScriptTools module ... yes
QtXmlPatterns module ... yes
Phonon module .......... no
Multimedia module ...... auto
SVG module ............. yes
WebKit module .......... no
可以看到webkit模块没有配置。
2、解决
Warning: -no-xrender will disable the QtWebkit module.
安装libxrender-dev:sudo apt-get install libxrender-dev
可能会提示一些需要安装的依赖库,按照提示按就可以了:sudo apt-get -f (安装所以所依赖的库)
3、重新配置编译安装qt4.8.6
make confclean
./configure
注意现在终端打印的信息:
This target is using the GNU C++ compiler (linux-g++).
Recent versions of this compiler automatically include code for exceptions, which increase both the size of the Qt libraries and the amount of memory taken by your applications.You may choose to re-run configure with the -no-exceptions option to compile Qt without exceptions. This is completely binary compatible, and existing applications will continue to work.
Build type:linux-g++
Architecture: i386
Platform notes:
- Also available for Linux: linux-kcc linux-icc linux-cxx
Build .................. libs tools examples demos docs translations
Configuration .......... release largefile stl precompile_header mmx 3dnow sse sse2 sse3 ssse3 sse4_1 sse4_2 avx minimal-config small-config medium-config large-config full-config qt3support accessibility opengl shared reduce_exports ipv6 clock-gettime clock-monotonic mremap getaddrinfo ipv6ifname getifaddrs inotify png freetype system-zlib nis iconv openssl xshape xsync xrender mitshm xkb concurrent xmlpatterns multimedia audio-backend svg script scripttools declarative release
Debug .................. no
Qt 3 compatibility ..... yes
QtDBus module .......... no
QtConcurrent code ...... yes
QtGui module ........... yes
QtScript module ........ yes
QtScriptTools module ... yes
QtXmlPatterns module ... yes
Phonon module .......... no
Multimedia module ...... auto
SVG module ............. yes
WebKit module .......... yes
JavaScriptCore JIT ..... To be decided by JavaScriptCore
Declarative module ..... yes
Declarative debugging ...yes
没有了警告信息,而且显示WebKit module .......... yes
继续
make
make install
4、安装完成进入qt安装目录/usr/local/Trolltech/Qt-4.8.6/include里面也包括了QtWebKit文件
现在#include <QWebView>#include <QWebFrame>#include <QWebView>可以正常使用。