I couldn't find any function in Qt 5 to determine which chromium version is used by QtWebEngine
.
I don't want to hard-code the chromium version in my code because I frequently update my application and the chromium version is usually changed in each version. And also Qt is backward-compatible and it is possible to update it without updating my application.
There is no direct solution but looking at the source code You can see that it is used to set the default user agent:
std::string ContentBrowserClientQt::getUserAgent()
{
// Mention the Chromium version we're based on to get passed stupid UA-string-based feature detection (several WebRTC demos need this)
return content::BuildUserAgentFromProduct("QtWebEngine/" QTWEBENGINECORE_VERSION_STR " Chrome/" CHROMIUM_VERSION);
}
So it can be extracted from that data:
QString version;
QString user_agent = QWebEngineProfile::defaultProfile()->httpUserAgent();
for(const QString & text : user_agent.split(" ")){
if(text.startsWith(QStringLiteral("Chrome/"))){
version = text.mid(QStringLiteral("Chrome/").length());
}
}
qDebug().noquote()<< "Qt version:" << QT_VERSION_STR << "chromium version:" << version;
Output:
Qt version: 5.14.2 chromium version: 77.0.3865.129