0

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

enter image description here

And this is how it looks after suspend. Sometimes even the names list has grey background

enter image description here

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?

danielhrisca
  • 665
  • 1
  • 5
  • 11
  • Your screenshots have too many color depending on the context. Can you clarify exactly *what* colors have not being maintained? – musicamante Dec 06 '22 at 15:08
  • IN the screenshot you can see the grey parts on the top menu and between the left toolbar and the vertical qtabwidget – danielhrisca Dec 07 '22 at 10:54
  • Ok, now I see it. Is that the only difference? So, basically, the main window background is the only color that is reset? How are you setting the palette? What does `set_theme()`? And why are you toggling the visibility of the window? Please provide a more comprehensive [mre]. – musicamante Dec 07 '22 at 18:22

0 Answers0