How to pass parameters to Chromium in QtWebEngine

We have talked about programming with Qt WebEngine. Every time you create a QWebEngineView object, you’ll start a QtWebEngineProcess.exe process. The process corresponds to the Chromium browser Qt WebEngine is based on. Chromium is a complex browser with a number of features. It can be controlled with various flags or options. How to specify the options or flags for Chromium? You’ve two choices:

  • Pass the flags as the arguments of your application, e.g., .\yourprogram.exe –ignore-certificate-errors –ignore-ssl-errors –log-level=3. Your program does not need or handle these parameters. But when your program starts the  QtWebEngineProcess.exe process, these parameters will be passed to it to control the behavior of Chromium,i.e, ignoring the certification error, outputting less log information,etc. By default, chromium will output a lot of log information likeERROR:ssl_client_socket_impl.cc(1050)] handshake failed; returned -1, SSL error code 1, net_error -100

    These are not fatal errors and can be ignored in most cases. Use proper Chromium flags to  suppress the error messages and make a clean output.

  • Create an environment variable QTWEBENGINE_CHROMIUM_FLAGS containing the flags you want to pass to chromium, i.e.,QTWEBENGINE_CHROMIUM_FLAGS=–ignore-certificate-errors –ignore-ssl-errors –log-level=3

 

Posted in

Leave a Reply