New webkit shipping with QT5 has a new structure. QWebView, QWebpage, etc. are now part of QtWebKitWidgets.
So in your code you need to include webview like this:
#include <QtWebKitWidgets/QWebView>
and in your .pro file your need to add:
QT += webkitwidgets
If you really want to make your code forward/backwards compatible; I would just have a check for QT5:
QT+= core gui webkit
contains(QT_VERSION, ^5.*) {
QT += webkitwidgets
}
...
and then in your code:
#if (QT_VERSION < 0x050000)
#include <QWebView>
#else
#include <QtWebKitWidgets/QWebView>
#endif