@stryga42 Thank you for your reply, what I want to do is on the Mac system, when I switch the desktop space, let the window switch with it and display it on the top layer forever. What I did try is as follows:
// in .mm file, My own widget is subclass of QWidget
NSPanel *window = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, size.width(), size.height()) styleMask:NSWindowStyleMaskFullSizeContentView | NSWindowStyleMaskBorderless | NSWindowStyleMaskNonactivatingPanel backing:NSBackingStoreBuffered defer:YES];
[window setHasShadow:false];
[window setHidesOnDeactivate:false];
[window setBackgroundColor:NSColor.clearColor];
[window setTitlebarAppearsTransparent:true];
[window setTitleVisibility:NSWindowTitleHidden];
[window setFloatingPanel:true];
[window setLevel:NSScreenSaverWindowLevel - zPosition];
[window setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary];
NSView *nativeWidgetView = (NSView*)(this->winId());
window.contentView = nativeWidgetView;
This approach achieved my purpose, but it also caused a series of event distribution problems, such as not receiving QEvent::Enter...I don't know what to do and if there is any other way to do it?