use QQuickRenderControl

Jimmy Girardet ijkl at netc.fr
Wed Jan 6 13:42:18 GMT 2021


I can't C++ so I try to guess. There are python example for almost 
everything  so until nowI didn't have this problem. I also looked into 
the opengl examples 
(https://github.com/PyQt5/Examples/tree/master/PyQt5/opengl) but it 
doesn't use QQuickRenderControl.

I tried with to follow more the c++ example:

class RenderControl(QQuickRenderControl):
     def __init__(self, w: QWindow):
         super().__init__()
         self.m_window = w
     def renderWindow(self, offset: QPoint = None):
         if (offset):
             offset = QPoint(0, 0)
         return self.m_window

and later :

self.m_renderControl = RenderControl(self)
self.m_quickWindow = QQuickWindow(self.m_renderControl)

but still get :

   File "main.py", line 58, in __init__
     self.m_quickWindow = QQuickWindow(self.m_renderControl)
TypeError: QQuickWindow(parent: QWindow = None): argument 1 has unexpected type 'RenderControl'


I really don't know what I could change


Le 06/01/2021 à 11:29, Phil Thompson a écrit :
> On 06/01/2021 10:17, Jimmy Girardet wrote:
>> Hi, happy new Year,
>>
>> I was using QQuickRenderControl with pyside2 :
>>
>> https://github.com/jgirardet/MyCartable/blob/dev/src/mycartable/conversion/grabber.py 
>>
>>
>>
>> I can't make it work with PyQt5. One problematic line is line 45 :
>>
>> self.m_quickWindow = QQuickWindow(self.m_renderControl)
>>
>> QQuickWindow with pyqt5 doesn"t accept QQuickREnderControl as parent
>> (but it seems C++ does
>> https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quick/rendercontrol/window_singlethreaded.cpp?h=5.15#n119) 
>>
>
> No it doesn't, you are misreading the C++ code.
>
>> So how could I use QQuickRenderControl with pyqt5, do you have an 
>> example ?
>
> Do what the C++ code is actually doing, not what you think it is doing.
>
>> More generally I just want to render some QML offscreen and grab the
>> content. Do you have any other way to do it ?
>
> Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210106/1d70b5f0/attachment.htm>


More information about the PyQt mailing list