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. How to use NSWindowController on MacOS

How to use NSWindowController on MacOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
macos
2 Posts 2 Posters 461 Views
  • 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.
  • D Offline
    D Offline
    Dmitriano
    wrote on last edited by Dmitriano
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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