简体   繁体   English

从基于C ++ / QT的应用程序访问NSWindow

[英]Accessing NSWindow from C++/QT-based application

I have an application that is written in C++ and is using QT as a framework. 我有一个用C ++编写的应用程序,并且正在使用QT作为框架。 The compiler is gcc and the IDE is QT Creator. 编译器是gcc,IDE是QT Creator。

On Mac OS, I need my app to interface with Spaces by accessing the collectionBehavior property of the NSWindow. 在Mac OS上,我需要通过访问NSWindow的collectionBehavior属性来使我的应用程序与Spaces交互。 So there should be a kind of a bridge from C++ app to NSWindow. 因此,应该存在从C ++应用程序到NSWindow的桥梁。

Can someone give me the hint on if/how this could be possible either with my current gcc/qtcreator setup (which I don't think is possible) or under xcode? 有人可以通过我当前的gcc / qtcreator设置(我认为不可能)还是在xcode下给我提示是否/如何做到这一点?

If you're using Cocoa Qt (there are 2 versions of Qt - Cocoa and Carbon, remember that!), you can use winId() on QWidget class to retrieve native widget handle. 如果您使用的是Cocoa Qt(Qt有2个版本-Cocoa和Carbon,请记住!),则可以在QWidget类上使用winId()来检索本机窗口小部件句柄。

On Qt Carbon QWidget::winId() returns HIViewRef, on Qt Cocoa it return NSView. 在Qt Carbon上,QWidget :: winId()返回HIViewRef,在Qt Cocoa上返回NSView。 I gues you can retrieve somehow NSWindow from NSView 我猜你可以从NSView检索NSWindow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM