<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Replacing QMacCocoaViewContainer with QWidget::createWindowContainer().]]></title><description><![CDATA[<p dir="auto">Hi guys. I'm trying to replace QMacCocoaViewContainer with QWidget::createWindowContainer().</p>
<p dir="auto">The code is:</p>
<p dir="auto">static inline void setupLayout(NSView *cocoaView, QWidget *parent) {<br />
parent-&gt;setAttribute(Qt::WA_NativeWindow);<br />
QVBoxLayout *layout = new QVBoxLayout(parent);<br />
layout-&gt;setMargin(0);<br />
layout-&gt;addWidget(new QMacCocoaViewContainer(cocoaView, parent));<br />
}</p>
<p dir="auto">I've tried QWidget::createWindowContainer(QWindow::fromWinId(parent-&gt;winId()), parent);</p>
<p dir="auto">The code is here: <a href="https://github.com/strawberrymusicplayer/strawberry/blob/master/src/widgets/qocoa_mac.h" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/strawberrymusicplayer/strawberry/blob/master/src/widgets/qocoa_mac.h</a><br />
This is just a helper function that is used in qsearchfield_mac.mm. The class is QSearchField that was written by Mike McQuaid, the class is different for macOS, written in objective C using Qocoa to have a native macOS look.</p>
]]></description><link>https://forum.qt.io/topic/117145/replacing-qmaccocoaviewcontainer-with-qwidget-createwindowcontainer</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 19:26:23 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/117145.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Jul 2020 21:20:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replacing QMacCocoaViewContainer with QWidget::createWindowContainer(). on Wed, 08 Dec 2021 15:33:18 GMT]]></title><description><![CDATA[<p dir="auto">This was, in fact, very helpful - I came here looking for how to replace QMacCocoaViewContainer which is no longer available in Qt 6.<br />
Or is there a way to bring it back in Qt 6.2?</p>
<p dir="auto">P. S. The method described here works in Qt 5.15 and 6.2, tested on macOS 11.6 and 12.0 The only downside is you can't inherit from the native widget, i. e. make it an instance of your subclass.</p>
]]></description><link>https://forum.qt.io/post/693751</link><guid isPermaLink="true">https://forum.qt.io/post/693751</guid><dc:creator><![CDATA[Violet Giraffe]]></dc:creator><pubDate>Wed, 08 Dec 2021 15:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to Replacing QMacCocoaViewContainer with QWidget::createWindowContainer(). on Thu, 01 Oct 2020 22:19:43 GMT]]></title><description><![CDATA[<p dir="auto">Posting a piece of code without sufficient context (working environment, version of the software) and then being rude if someone asks is also unhelpful.</p>
<p dir="auto">Things change both in Qt and in the system, it is often hard to give correct answer without knowing the above.</p>
]]></description><link>https://forum.qt.io/post/620227</link><guid isPermaLink="true">https://forum.qt.io/post/620227</guid><dc:creator><![CDATA[artwaw]]></dc:creator><pubDate>Thu, 01 Oct 2020 22:19:43 GMT</pubDate></item><item><title><![CDATA[Reply to Replacing QMacCocoaViewContainer with QWidget::createWindowContainer(). on Thu, 01 Oct 2020 18:20:32 GMT]]></title><description><![CDATA[<p dir="auto">I had to look into the source code of QMacCocoaViewContainer to find the answer here.</p>
<p dir="auto">The solution is: QWidget::createWindowContainer(QWindow::fromWinId(WId(cocoaView))<br />
Where cocoaView is the NSView.</p>
<p dir="auto">(6 questions to a simple question like this is very unhelpful, if you knew how to help with it you would have known the answer by looking at the code I shared).</p>
]]></description><link>https://forum.qt.io/post/620167</link><guid isPermaLink="true">https://forum.qt.io/post/620167</guid><dc:creator><![CDATA[Jonas Kvinge]]></dc:creator><pubDate>Thu, 01 Oct 2020 18:20:32 GMT</pubDate></item><item><title><![CDATA[Reply to Replacing QMacCocoaViewContainer with QWidget::createWindowContainer(). on Sun, 19 Jul 2020 18:27:32 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What is happening ?<br />
What is the issue ?<br />
Which version Of Qt ?<br />
Which version of macOS ?</p>
<p dir="auto">And out of curiosity, why do you want to switch ?</p>
]]></description><link>https://forum.qt.io/post/607699</link><guid isPermaLink="true">https://forum.qt.io/post/607699</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 19 Jul 2020 18:27:32 GMT</pubDate></item></channel></rss>