5

My Qt application (that will run on Windows, OS X and Ubuntu) has a need to:

  1. List all windows everywhere
  2. Obtain their caption text (if any)
  3. Obtain an Icon of the application, if any, as QIcon or QPixmap (e.g. App Icon)
  4. Obtain some kind of unique ID about them (e.g. HWND on windows)

I know how to do this for Windows using Win32. I can research Mac and Ubuntu separately, but I was wondering if there's an abstracted/unified Qt approach to assist me?

JasonGenX
  • 4,952
  • 27
  • 106
  • 198

2 Answers2

5

Nope, those are OS specific:

http://www.qtcentre.org/threads/41730-How-to-enumerate-all-top-level-windows

As for starting down the quest of what's doable through published APIs...some X11 hints here:

How to identify top-level X11 windows using xlib?

On Macs, the "forward-looking" way to build Qt is against "Cocoa" instead of "Carbon":

http://doc.qt.nokia.com/latest/developing-on-mac.html#carbon-or-cocoa

And according to other SOers, it's the accessibility API (which has to be enabled by users, it seems) that can do this enumeration:

Get a list of opened windows cocoa

Mac / Cocoa - Getting a list of windows using Accessibility API

Then the question becomes how inside of a C++ application to make "calls out" to Cocoa APIs which are natively Objective-C:

How to mix Qt, C++ and Obj-C/Cocoa

...or you could just not do this. :-)

Community
  • 1
  • 1
0

I would suggest keeping track of this information yourself. It wouldn't be perfect (just have a singleton class and overload the setWindowTitle() calls in your root window types) but would be platform-independent . . .

kestrel
  • 1,314
  • 10
  • 31