Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Notify when any window of a QApplication is shown
Forum Updated to NodeBB v4.3 + New Features

Notify when any window of a QApplication is shown

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 357 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ewan Green
    wrote on last edited by Ewan Green
    #1

    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 the winId() 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

    J.HilkJ 1 Reply Last reply
    0
    • E Ewan Green

      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 the winId() 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.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Ewan-Green I think you would get away with a simple Custom Event filter, applied on your QApplication, that listens for QShowEvents

      https://doc.qt.io/qt-6/eventsandfilters.html#event-filters


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • E Offline
        E Offline
        Ewan Green
        wrote on last edited by
        #3

        This is exactly what I was looking for, thank you.

        Ewan Green

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved