[Interest] Showing QGuiApplication/QML application on a given HWND ref.
Nuno Santos
nunosantos at imaginando.pt
Thu Jun 4 14:50:38 CEST 2015
Hamish,
Your tip was right.
QWindow::fromWinId is expecting a NSView:
plugins/platforms/cocoa/qcocoawindow.mm: NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
But what I’m giving is a Carbon WindowRef.
I have found code to make an NSWindow from WindowRef:
You can create an NSWindow object for a Carbon window by allocating an NSWindow object and
then initializing the object using the initWithWindowRef: method, as shown in the following line of
code:
cocoaFromCarbonWin = [[NSWindow alloc] initWithWindowRef:window];
Do you think is my responsibility to create the NSWindow and then the NSView to provide to fromWinId?
Thanks,
Regards,
Nuno
> On 04/06/2015, at 09:34, Hamish Moffatt <hamish at risingsoftware.com> wrote:
>
> On 04/06/15 17:44, Nuno Santos wrote:
>> Hi,
>>
>> Unfortunately this technic doesn’t seem to be working on Mac. Not sure if this is a BUG.
>>
>> It is able to create the QQuickView, but as soon as it instantiates QQuickView, it crashes:
>>
>> if (!window)
>> {
>> window = QWindow::fromWinId((WId)ptr); // line that causes the crash
>>
>>
>> ...
>>
>> 2015-06-04 08:38:37.892 Live[88624:8396551] -[NSHIObject setPostsFrameChangedNotifications:]: unrecognized selector sent to instance 0x1b333860
>>
>> Does this say something to anyone?
>>
>
> "unrecognized selector" means a method was called that doesn't exist. Or more likely, the object you passed to fromWinId was not the type that the Cocoa platform plugin expected.
>
> The platform plugin is expecting an NSView*, and maybe what you have is an NSWindow*. (I don't know much about Cocoa.) Or maybe it's not a Cocoa window at all?
>
>
> Hamish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150604/853d6a95/attachment.html>
More information about the Interest
mailing list