c++qtqt5chromiumqtwebengine

Get chromium version of QtWebengine without starting QtApplication


I have a custom browser using QtWebEngine which I can start from the commandline and pass it a website. It also has a --version option which if set prints out the browser version, QtWebengine version and chromium version used. However to read the chromium version specifically the browser has to start a Qt WebEngine instance just to call a single function so it can retrieve the version. This takes about 1-2 seconds of time for just displaying the version.

Is there another way to retrieve the chromium version? Currently my code to retrieve the version looks like this:

QApplication dummyapp(size, argvec.data());
// read chromium version in userAgent string
QString userAgent(QWebEngineProfile::defaultProfile()->httpUserAgent());
auto match = QRegularExpression("QtWebEngine/(\\S+)\\s*Chrome/(\\S+)").match(userAgent);
QString webengineVersion = match.hasMatch() ? match.captured(1) : "unknown";
QString chromiumVersion = match.hasMatch() ? match.captured(2) : "unknown";

I can easily find get the browser and webengine version without initating the webengine first but not chromium. You can assume that chrome or chromium itself is not installed on the system running the browser.

Simply running the code above without initiating the QApplication doesnt work. I also tried looking for the version string on the entire system and have not found it anywhere using sudo grep -Rnw / -e 87.0.4280.144.


Solution

  • As mentioned by @Botje in Qt6.2+ you can use https://doc.qt.io/qt-6/qtwebenginecoreglobal-h.html#qWebEngineChromiumVersion.