I'm using the Fusion style for my application. I define a dark theme by customizing the palette. With the dark theme active, it sometimes happens that the palette colors are partially lost when the PC goes to sleep or is suspended.
This is how the application normally looks like
And this is how it looks after suspend. Sometimes even the names list has grey background
To mitigate this I've added an event filter but it doesn't seem to do the job. The palette is re-applied in the set_theme method
class WinEventFilter(QtCore.QAbstractNativeEventFilter):
def __init__(self):
super().__init__()
self.main_window = None
def nativeEventFilter(self, event_type, message):
if event_type == b"windows_generic_MSG":
msg = ctypes.wintypes.MSG.from_address(message.__int__())
if msg.message == 0x15 and self.main_window is not None:
self.main_window.hide()
self.main_window.set_theme(apply=True)
self.main_window.show()
return False, 0
win_event_filter = WinEventFilter()
app.installNativeEventFilter(win_event_filter)
Any idea how to fix this?