Enabling macOS Wallpaper Tinting
-
For a while now, macOS has had an "Allow wallpaper tinting in windows" option which sort of tints the window color based on the wallpaper. It's a subtle effect, but noticeable when you compare a stark white QtWidgets window against a native mac application that can use the tinting.
I've asked around about a way to enable it in QtWidgets before, and for a while people were saying it wasn't possible unless you fake it one way or another. But recently ChatGPT gave me some code that seems to kind of work, but I don't blindly trust ChatGPT and I can't really find any documentation about this method that specifically says anything about window tinting. The code (Pyside6):
from PySide6.QtWidgets import QApplication, QMainWindow from PySide6.QtCore import Qt from PySide6.QtGui import QSurfaceFormat # Set up the surface format for translucency surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) QSurfaceFormat.setDefaultFormat(surface_format) app = QApplication([]) # Create the main window window = QMainWindow() # Enable translucency window.setAttribute(Qt.WA_TranslucentBackground) # Show the window window.show() app.exec()
Can anyone point me to any documentation at all, that has ever existed, specific to macOS Window Tinting with Qt? Or perhaps explain why adding an alpha channel to the QSurfaceFormat and setting a Translucent flag on the window seems to trigger support for Window Tinting?
I'm happy that it seems to work, but I don't understand how anyone would have been expected to figure this out, and I'd love to know if there are other parameters I can play with to affect how Qt responds to macOS's window tinting feature.