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. QWidget across the desktop space in macos?
Qt 6.11 is out! See what's new in the release blog

QWidget across the desktop space in macos?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 491 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.
  • Z Offline
    Z Offline
    Zuoyu Xie
    wrote on last edited by
    #1

    In macos, how can qwidget across the desktop space when I switch workspace?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stryga42
      wrote on last edited by
      #2

      I do not understand your question or issue. Could you please re-phrase or explain in more detail?

      Z 1 Reply Last reply
      0
      • S stryga42

        I do not understand your question or issue. Could you please re-phrase or explain in more detail?

        Z Offline
        Z Offline
        Zuoyu Xie
        wrote on last edited by
        #3

        @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?

        1 Reply Last reply
        0

        • Login

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