C++ (Qt)QVector <QWidget *> GetMacZOrderWinList( void ){ QVector <QWidget *> dst; NSInteger windowCount; NSCountWindows(&windowCount); if (windowCount <= 0) return dst; QWidgetList lst = QApplication::topLevelWidgets(); QHash<NSWindow *, QWidget *> hash; for (int i = 0; i < lst.size(); ++i) { QWidget * widget = lst[i]; NSView * view = (NSView *) widget->winId(); if (!view) continue; NSWindow * nsWin = [view window]; if (nsWin) hash[nsWin] = widget; } QVector <NSInteger> src(windowCount); NSWindowList(windowCount, &src[0]); for (int i = 0; i < windowCount; ++i) { NSWindow * window = [NSApp windowWithWindowNumber:src[i]]; if (!window) continue;// QWidget * w = QWidget::find((WId) window); // returns 0 QWidget * widget = hash.value(window); if (widget) dst.push_back(widget); } return dst;}