How to use NSWindowController on MacOS
Unsolved
General and Desktop
-
I have a QML app where I need to set ApplicationWindow aspect ratio somehow.
My idea is that I probably use the following native code on MacOS:
#import <Cocoa/Cocoa.h> NS_ASSUME_NONNULL_BEGIN @interface MyWindowController : NSWindowController @end NS_ASSUME_NONNULL_END #import "MyWindowController.h" @interface MyWindowController () @end @implementation MyWindowController - (void)windowDidLoad { [super windowDidLoad]; // set the aspect ratio here [self.window setAspectRatio:NSMakeSize(320.0, 640.0)]; } @end
but it is not clear how to assign my class to the Window Controller. And it is not clear is it created internally in QT or not.
-
Hi,
Unless I am mistaken, for what you want to do you do not need a NSWindowController.
Retrieve the NSWindow from your QWindow and apply the change you implemented.