2010-11-20 56 views
3

我刚开始使用Qt库。我试图编译我的第一个测试脚本与下面的头:如何在Linux中包含Qt库(qwebview.h)?

#include <qwebview.h> 

但是它不会编译:

g++ main.cpp -o run.main 
main.cpp:2:22: error: qwebview.h: No such file or directory 
main.cpp: In function ‘int main()’: 
main.cpp:10: error: ‘QWebView’ was not declared in this scope 

我有安装我的Linux的Kubuntu机器上的库:

$ locate qwebview 
/usr/include/qt4/Qt/qwebview.h 
/usr/include/qt4/QtWebKit/qwebview.h 
/usr/lib/qt4/plugins/designer/libqwebview.so 

我跑了ldconfig一次,以确保(我认为)可见的库,但显然,这是不够的。

如何设置我的机器以便我可以开始使用Qt编译软件?

回答

1
#include <QWebView> should work. 
+0

不,它不:( – augustin 2010-11-20 02:39:38

4

首先,使用正确的情况下,对于包括:

#include <QWebView> 

然后添加适当的包括路径编译:

g++ -c -I /usr/include/qt4 main.cpp 

然后对相应的库链接:

g++ -o main.run main.o -lQtCore -lQtGui -lQtWebKit 

如果这似乎太复杂,你尝试使用QMAKE ...

6

[your_library]的.pro文件添加

QT  += webkit 

然后

#include <QWebView> 

应该足以让这样的代码:

QWebView *view = new QWebView(parent); 
view->load(QUrl("http://qt.nokia.com/")); 

编译

希望这会有所帮助,关注