开发者

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

开发者 https://www.devze.com 2023-01-26 15:12 出处:网络
I am just starting to use the Qt library. I am trying to compile my very first test script with the following header:

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开发者_JAVA技巧 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?


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


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...


#include <QWebView> should work.
0

精彩评论

暂无评论...
验证码 换一张
取 消