Referencing WebKit or WebEngine in .ui file depending on Qt version
<p>I am attempting to upgrade a Qt application from 5.3.1 to 5.7.0. The main change is the migration from WebKit to WebEngine. 
<a href="http://doc.qt.io/qt-5/qtwebenginewidgets-qtwebkitportingguide.html" rel="nofollow noreferrer">http://doc.qt.io/qt-5/qtwebenginewidgets-qtwebkitportingguide.html</a></p>

<p>We are not yet ready to stop using 5.3.1, so I created a preprocessor define based on the Qt version. This works well for the project file, class source, and class header. However, I don't see a way to do this in the .ui file.</p>

<p>The Qt version is used to define a preprocessor define in the <code>.pro</code> file:</p>

<pre><code>greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets

    greaterThan(QT_MINOR_VERSION, 5) {
        QT += webengine webenginewidgets
        DEFINES += _WEBENGINE_
    } else {
        QT += webkit       webkitwidgets
    }
}
</code></pre>

<p>This works well in the <code>.cpp</code> file:</p>

<pre class="lang-cpp prettyprint-override"><code>#ifdef _WEBENGINE_
    #include &lt;QWebEngineView&gt;
    #include &lt;QWebEnginePage&gt;
    #include &lt;QWebEngineFrame&gt;
    #include &lt;QWebEngineElement&gt;
#else
    #include &lt;QWebView&gt;
    #include &lt;QWebPage&gt;
    #include &lt;QWebFrame&gt;
    #include &lt;QWebElement&gt;
#endif // _WEBENGINE_
</code></pre>

<p>These are the offending references in the <code>.ui</code> file:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;widget class="QWebView" name="webView" native="true"&gt;
...
&lt;/widget&gt;
...
&lt;customwidget&gt;
 &lt;class&gt;QWebView&lt;/class&gt;
 &lt;extends&gt;QWidget&lt;/extends&gt;
 &lt;header&gt;QtWebKit/QWebView&lt;/header&gt;
&lt;/customwidget&gt;
</code></pre>

<p>Which results in the <code>ui_*.h</code> file:</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;QtWebKitWidgets/QWebView&gt;
...
public:
    QWebView *webView;
</code></pre>

<p>How can I use the correct include paths and class names in the <code>.ui</code> file depending on the Qt version?</p>