Notify when any window of a QApplication is shown
-
Hello. I'm currently doing some title bar customization, which is pretty much unsupported by anything Qt has to offer. The intention is that it matches the stylesheet, which I can set on a qApp basis. The process of decorating the window title bar requires setting attributes of windows on a per-handle (
HWND/NSView */whatever) basis, but this is a problem because I don't have a good way to get thewinId()of every window that's going to be shown in my app. I looked through QApplication, which is the place I would expect to find such a thing (a signal, maybe?) but I didn't find anything that could help me.What I can do, which would not be ideal, is just run my title bar customization function on every single window as it's appropriate (single-shot timers in constructors,
showEvent()s, whatever). This wouldn't work for static methods (QMessageBox,QFileDialog) or modal dialogs (if I call it before exec(), the window handle is invalid; if I call it after, it won't be called because modal dialogs block), or really anything I don't subclass.I'd rather not have to do that since it's incomplete feature-wise and pretty messy/easy to forget to implement code-wise. Any help would be appreciated.
-
Hello. I'm currently doing some title bar customization, which is pretty much unsupported by anything Qt has to offer. The intention is that it matches the stylesheet, which I can set on a qApp basis. The process of decorating the window title bar requires setting attributes of windows on a per-handle (
HWND/NSView */whatever) basis, but this is a problem because I don't have a good way to get thewinId()of every window that's going to be shown in my app. I looked through QApplication, which is the place I would expect to find such a thing (a signal, maybe?) but I didn't find anything that could help me.What I can do, which would not be ideal, is just run my title bar customization function on every single window as it's appropriate (single-shot timers in constructors,
showEvent()s, whatever). This wouldn't work for static methods (QMessageBox,QFileDialog) or modal dialogs (if I call it before exec(), the window handle is invalid; if I call it after, it won't be called because modal dialogs block), or really anything I don't subclass.I'd rather not have to do that since it's incomplete feature-wise and pretty messy/easy to forget to implement code-wise. Any help would be appreciated.
@Ewan-Green I think you would get away with a simple Custom Event filter, applied on your QApplication, that listens for QShowEvents
-
This is exactly what I was looking for, thank you.