Update: I managed to get a QWindow involved into the code, yet the toolbar is messed up.
Screenshot
New code:
void Test::createFancyMacWindow() {
QWindow* w = new QWindow();
NSView* mainWindowNSView = (NSView*) w->winId();
NSWindow* window = [mainWindowNSView window];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// move toolbar where the titlebar used to be
[window setTitleVisibility: NSWindowTitleHidden];
// Adjust Cocoa layouts
NSView *contentView = [window contentView];
[contentView setAutoresizesSubviews:YES];
QMacNativeWidget *nativeWidget = new QMacNativeWidget(contentView);
//nativeWidget->move(0, 0);
nativeWidget->setPalette(QPalette(Qt::red));
nativeWidget->setAutoFillBackground(true);
NSView *nativeWidgetView = nativeWidget->nativeView();
[contentView addSubview:nativeWidgetView positioned:NSWindowAbove relativeTo:nil];
[nativeWidgetView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[nativeWidgetView setAutoresizesSubviews:YES];
nativeWidget->show();
// Show the window.
[window makeKeyAndOrderFront:window];
[pool release];
QMacToolBar *toolBar = new QMacToolBar();
toolBar->addItem(QIcon(), QStringLiteral("Helloooo"));
toolBar->attachToWindow(w);
[window setToolbar: toolBar->nativeToolbar()];
w->show();
}