Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing NSWindow from C++/QT-based application

I have an application that is written in C++ and is using QT as a framework. The compiler is gcc and the IDE is QT Creator.

On Mac OS, I need my app to interface with Spaces by accessing the collectionBehavior property of the NSWindow. So there should be a kind of a bridge from C++ app to 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?

like image 326
Dmitry S. Avatar asked Nov 28 '25 01:11

Dmitry S.


1 Answers

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.

On Qt Carbon QWidget::winId() returns HIViewRef, on Qt Cocoa it return NSView. I gues you can retrieve somehow NSWindow from NSView

like image 193
Kamil Klimek Avatar answered Nov 30 '25 15:11

Kamil Klimek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!