1

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.

3
  • In Qt 6.2 you can use qWebEngineChromiumVersion, maybe there's a private method in Qt 5 that does the same? Commented Sep 6, 2024 at 13:50
  • static std::string QtWebEngineCore::ContentBrowserClientQt::getUserAgent() is the function you want, according to this duplicate. Not sure if you can get at it though... Commented Sep 6, 2024 at 14:22
  • The suggestion for Qt 6.2 is exactly what im looking for thanks! I dont think I can access ContentBrowserClientQt::getUserAgent() for Qt5 without some hacks. Thanks though! @Botje Commented Sep 9, 2024 at 10:06

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

you can't accept your own answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.