How to include Qt libs (qwebview.h) in Linux?

augustin picture augustin · Nov 20, 2010 · Viewed 8.7k times · Source

I am just starting to use the Qt library. I am trying to compile my very first test script with the following header:

#include <qwebview.h>

However it won't compile:

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

I do have the libs installed on my Linux Kubuntu machine:

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

I ran ldconfig once to make sure (I think) that the libs are seen, but apparently, it's not enough.

How to I set up my machine so that I can start compiling software with Qt?

Answer

serge_gubenko picture serge_gubenko · Nov 20, 2010

in you [your_library].pro file add

QT       +=  webkit

then

#include <QWebView>

should be sufficient to get this code:

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

compiled

hope this helps, regards