Frage

Hello there I'm creating a simple window which uses a QWebView to display web content in it.

In my mainwindow.cpp file i add: #include <QWebView> (also tried #include <QtWebKitWidgets/QWebView>)

in my .pro file I added: QT += webkit webkitwidgets

But I still get a build error: QWebView: No such file or directory.

I'm using Qt Creator (Qt4) under arch linux. Can anyone help me? Thanks in advance

War es hilfreich?

Lösung

I am also using Archlinux for Qt 4 purposes, and the issue is this:

QT += webkit webkitwidgets
             ^^^^^^^^^^^^^

The Qt GUI was separated into QtGui and QtWidgets in Qt 5. That also included the restructuring of the QtWebKit module to reflect the changes.

Therefore, in Qt 4, there were no separate widget modules. That means, you should only write the following and that will work:

QT += webkit

Notice the webkitwidgets line removed. If you really fancy this, and wish to use Qt 5 later while being compatible with Qt 4, you could write this condition check:

QT += webkit
greaterThan(QT_MAJOR_VERSION, 4):QT+=webkitwidgets
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top