How to enable Qt libs (qwebview.h) on Linux?

I'm just starting to use the Qt library. I am trying to compile my first test script with the following heading:

#include <qwebview.h>

However, it will not compile:

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

I have libs installed on my Kubuntu Linux machine:

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

I ran ldconfigonce to make sure (I think) that the libraries are visible, but apparently this is not enough.

How to configure my computer so that I can start compiling software using Qt?

+3
source share
3 answers

in the [your_library] .pro file add

QT       +=  webkit

then

#include <QWebView>

should be enough to get this code:

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

compiled

hope this helps, believes

+6

-, include:

#include <QWebView>

include :

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

:

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

, qmake...

+4
#include <QWebView> should work.
+1
source

Source: https://habr.com/ru/post/1775931/


All Articles