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
Forum Updated to NodeBB v4.3 + New Features

How to use NSWindowController on MacOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
macos
2 Posts 2 Posters 492 Views 2 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.
  • D Offline
    D Offline
    Dmitriano
    wrote on 26 Oct 2022, 17:01 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Oct 2022, 18:43 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

      1/2

      26 Oct 2022, 17:01

      • Login

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