0

I am currently adding support of QWebEngineWidgets to my older applications but I don't want to loose QWebKitWidgets. because in some embeded platforms the qt version is still 5.3. I wonder if the following solution I made by myself is correct and better solutions is also welcome.

equals(QT_MAJOR_VERSION, 5) {
    lessThan(QT_MINOR_VERSION, 5) {
        QT += webkitwidgets
    }
    greaterThan(QT_MINOR_VERSION, 4) {
        QT += webenginewidgets
    }
}
AMCoded
  • 1,374
  • 2
  • 24
  • 39
  • alternatively you could consider using https://trac.webkit.org/wiki/QtWebKit on newer versions – Kevin Krammer Feb 25 '17 at 09:55
  • wow, I have n't seen this before. webkit was quite sth that webengine could not replace it. you could almost parse html tags with webkit one by one. I hope it ported back to qt with this project. – AMCoded Feb 25 '17 at 22:11

1 Answers1

1

You can also use "else" for the alternative branch, e.g.

lessThan(QT_MINOR_VERSION, 5) {
} else {
}

or even check for a module's availability specifically

qtHaveModule(webengine) {
}
Kevin Krammer
  • 5,159
  • 2
  • 9
  • 22
  • Is it possible to use the else with qtHaveModule block and is there a relevant to this macro in cpp source code. e.g. sth we could use with #if – AMCoded Feb 25 '17 at 22:13
  • Yes, you can use an else with that. I am not sure if there is a standard define, but you can always set your own defines in the `.pro` file, e.g: `DEFINES += HAVE_WEBENGINE` and then check for it in your code: `#ifdef HAVE_WEBENGINE` – Kevin Krammer Feb 26 '17 at 08:58