Search code examples
pythonpyqt5chromiumpyside6darkmode

How to use the chromium dark mode flag (--enable-force-dark) in PySide6?


I am making a browser based on Chromium with PySide6 (almost the same as PyQt6).

import os 
import sys 

os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--enable-force-dark"

app = QApplication(sys.argv)

When I run this code with the rest of my PySide6 application, it runs like normal, without any errors.

I expected the sites to be dark mode, but that is not the case. I went to chrome flags and tuned on enable-force-dark and chrome made all my websites dark mode.

Could someone tell me what I'm doing wrong?

I used this for reference by the way.


Solution

  • To fix this, simply remove sys.argv from QApplication().