[Interest] Showing QGuiApplication/QML application on a given HWND ref.

Nuno Santos nunosantos at imaginando.pt
Thu Jun 4 09:44:58 CEST 2015


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

	...

QML debugging is enabled. Only use this in a safe environment.
creating instance of patch model
finalizing vst
finalizing editor
finalizing app
destroying editor
2015-06-04 08:38:36.885 Live[88624:8396551] _DPSDiscardEvents: FlushEventsMatchingListFromQueue returned error (-50)
creating instance of patch model
2015-06-04 08:38:37.892 Live[88624:8396551] -[NSHIObject setPostsFrameChangedNotifications:]: unrecognized selector sent to instance 0x1b333860
2015-06-04 08:38:37.892 Live[88624:8396551] -[NSHIObject setPostsFrameChangedNotifications:]: unrecognized selector sent to instance 0x1b333860
2015-06-04 08:38:38.472 Live[88624:8396551] (
	0   CoreFoundation                      0x94787c63 __raiseError + 195
	1   libobjc.A.dylib                     0x996d0a2a objc_exception_throw + 276
	2   CoreFoundation                      0x9478c7c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
	3   CoreFoundation                      0x946c2758 ___forwarding___ + 1032
	4   CoreFoundation                      0x946c232e _CF_forwarding_prep_0 + 14
	5   drc                                 0x1e375970 _ZN12QCocoaWindow14recreateWindowEPK15QPlatformWindow + 960
	6   drc                                 0x1e37526a _ZN12QCocoaWindowC2EP7QWindow + 1146
	7   drc                                 0x1e371295 _ZNK17QCocoaIntegration20createPlatformWindowEP7QWindow + 37
	8   drc                                 0x1e7a9439 _ZN14QWindowPrivate6createEb + 57
	9   drc                                 0x1e7accbf _ZN7QWindow9fromWinIdEj + 207
	10  drc                                 0x1dd60fed _ZN10IVstEditor4openEPv + 61

Does this say something to anyone?

Regards,

Nuno


> On 03/06/2015, at 18:11, Nuno Santos <nunosantos at imaginando.pt> wrote:
> 
> Hey Bo,
> 
> Just wanted to share with you some progress.
> 
> Actually Qt makes it really simple. I was amazed I could do it with a just 5 lines of code. (Qt ROCKS!)
> 
> Right now, I just have a problem. The plugin window opens and closes perfectly. But once open, if I delete the plug in from the host and the QApplication is deleted, it crashes. Still can't figure it why.
> 
> See below my simple solution for this case. I problably know it yourself. I'm sharing it anyway.
> 
> bool IVstWrapperEditor::open(void *ptr)
> {
>     AEffEditor::open(ptr);
> 
>     if (!window)
>     {
>         window = QWindow::fromWinId((WId)ptr);
> 
>         view = new QQuickView(window);
>         view->setSource(QUrl(QStringLiteral("qrc:/main.qml")));
>         view->rootContext()->setContextProperty("controller", _controller);
>         view->show();
> 
>         return true;
>     }
> 
>     return false;
> }
> 
> void IVstWrapperEditor::close()
> {
>     if (window)
>     {
>         qDebug() << "destroying view";
>         view->deleteLater();
>         view=0;
> 
>         qDebug() << "destroying window";
>         window->deleteLater();
>         window=0;
>     }
> 
>     AEffEditor::close();
> }
> 
> Regards,
> 
> Nuno
> 
> On 03/06/2015 11:56, Nuno Santos wrote:
>> In my case I have a related app which opens the plugin. 
>> 
>> The host provides a window handle to the plugin.
>> 
>> I was trying to make that handle into a QWidget with the following code:
>> 
>> MyWindow::MyWindow(void* ptr) :
>>     QWidget(0)
>> {
>>     HWND w = (HWND) ptr;
>> 
>>     setGeometry(QRect(0,0,640,480));
>> 
>>     QPalette Pal(palette());
>> 
>>     // set black background
>>     Pal.setColor(QPalette::Background, Qt::black);
>>     setAutoFillBackground(true);
>>     setPalette(Pal);
>> 
>>     create((WId)w, false, false);
>> }
>> 
>> The problem is that two windows appear, the one the host provides and the one created by QWidget.
>> 
>> It seems that the create call is not working as intended.
>> 
>> MyWindow subclasses QWidget in order to call the create method since it’s protected.
>> 
>> Do you have any clue why this technic isn’t working?
>> 
>> Thanks,
>> 
>> Nuno Santos
>> Founder / CEO / CTO
>> www.imaginando.pt <http://www.imaginando.pt/>
>> +351 91 621 69 62
>> 
>>> On 03 Jun 2015, at 11:37, Bo Thorsen <bo at vikingsoft.eu <mailto:bo at vikingsoft.eu>> wrote:
>>> 
>>> Den 03-06-2015 kl. 12:35 skrev Nuno Santos:
>>>> Thanks for sharing your code.
>>>> 
>>>> I will try and give some feedback.
>>>> 
>>>> Any thoughts regarding the initial approach? Is there any reason for you
>>>> not having followed that path?
>>> 
>>> My application inserts an overlay over a complete unrelated application (the pokerstars or bet365 poker clients actually), so this is the only approach that can work.
>>> 
>>> Bo Thorsen,
>>> Director, Viking Software.
>>> 
>>> -- 
>>> Viking Software
>>> Qt and C++ developers for hire
>>> http://www.vikingsoft.eu <http://www.vikingsoft.eu/>
>> 
>> 
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150604/54958dca/attachment.html>


More information about the Interest mailing list