augustin
augustin

Reputation: 14729

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

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?

Upvotes: 3

Views: 8961

Answers (3)

serge_gubenko
serge_gubenko

Reputation: 20482

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

Upvotes: 6

chris
chris

Reputation: 4026

First, use the proper case for the include:

#include <QWebView>

Then add the proper include path to the compiler:

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

Then link against the appropriate libraries:

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

If this seems too complicated to you try using qmake...

Upvotes: 4

anders
anders

Reputation: 782

#include <QWebView> should work.

Upvotes: 1

Related Questions