PyQt6.uic Unknown Qt widget: QOpenGLWidget

Phil Thompson phil at riverbankcomputing.com
Tue Jan 2 09:50:14 GMT 2024


On 01/01/2024 18:02, John Thornton wrote:
> I have a simple ui file with just an QOpenGLWidget, when I try and run
> the file I get this error.
> 
> Traceback (most recent call last):
>   File "/home/john/github/pyqt6/QOpenGLWidget/./oglw6-10.py", line 18,
> in <module>
>     gui = main()
>           ^^^^^^
>   File "/home/john/github/pyqt6/QOpenGLWidget/./oglw6-10.py", line 12,
> in __init__
>     uic.loadUi('oglw6-10.ui', self)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/load_ui.py", line 86, 
> in loadUi
>     return DynamicUILoader(package).loadUi(uifile, baseinstance)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/Loader/loader.py",
> line 62, in loadUi
>     return self.parse(filename)
>            ^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 1014, in parse
>     self._handle_widget(ui_file.widget)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 842, in _handle_widget
>     self.traverseWidgetTree(el)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 818, in traverseWidgetTree
>     handler(self, child)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 280, in createWidget
>     self.traverseWidgetTree(elem)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 818, in traverseWidgetTree
>     handler(self, child)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 512, in createLayout
>     self.traverseWidgetTree(elem)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 818, in traverseWidgetTree
>     handler(self, child)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 555, in handleItem
>     self.traverseWidgetTree(elem)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 818, in traverseWidgetTree
>     handler(self, child)
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 271, in createWidget
>     self.stack.push(self._setupObject(widget_class, parent, elem))
>                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/uiparser.py", line
> 233, in _setupObject
>     obj = self.factory.createQtObject(class_name, object_name,
>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/PyQt6/uic/objcreator.py", line
> 117, in createQtObject
>     raise NoSuchWidgetError(ctor_name)
> PyQt6.uic.exceptions.NoSuchWidgetError: Unknown Qt widget: 
> QOpenGLWidget
> 
> I grepped for QOpenGLWidget in
> /usr/lib/python3/dist-packages/PyQt6/uic and found it in
> 
> john at cave:/usr/lib/python3/dist-packages/PyQt6/uic$ grep -irn 
> 'QOpenGLWidget' *
> grep: Compiler/__pycache__/qtproxies.cpython-311.pyc: binary file 
> matches
> Compiler/qtproxies.py:302:        "QLineEdit", "QMainWindow",
> "QMenuBar", "QOpenGLWidget",
> 
> Checking PyQt5 (which works) I find on a slightly different line
> 
> john at cave:/usr/lib/python3/dist-packages/PyQt5/uic$ grep -irn 
> 'QOpenGLWidget' *
> grep: Compiler/__pycache__/qtproxies.cpython-311.pyc: binary file 
> matches
> Compiler/qtproxies.py:289:        "QLineEdit", "QMainWindow",
> "QMenuBar", "QOpenGLWidget",
> 
> I'm running
> 
> john at cave:~$ uname -a
> Linux cave 6.1.0-10-rt-amd64 #1 SMP PREEMPT_RT Debian 6.1.38-1
> (2023-07-14) x86_64 GNU/Linux
> 
> and PyQt is installed from Debian
> 
> Thanks
> 
> JT

Fixed in the next snapshot.

Thanks,
Phil


More information about the PyQt mailing list