PyQt6 ui parsing bug (and a solution)

Phil Thompson phil at riverbankcomputing.com
Fri Nov 19 12:25:34 GMT 2021


On 18/11/2021 20:49, Marijan Smetko wrote:
> Hello,
> 
> I was playing with PyQt6 and I've encountered a bug with uic.
> 
> I have attached the untitled.ui file and the main.py file. when
> running `python3 main.py` it breaks with the following error:
> 
> ```
> 
> Traceback (most recent call last):
>   File "/home/msmetko/Projects/qt/main.py", line 12, in <module>
>     window = Ui()
>     ...
>     ...
>   File
> "/home/msmetko/Projects/qt/venv/lib/python3.9/site-packages/PyQt6/uic/uiparser.py",
> line 62, in _parse_alignment
>     align = getattr(QtCore.Qt, qt_align)
> AttributeError: type object 'Qt' has no attribute 'AlignHCenter'
> 
> I was running the main.py inside a freshly made venv with these 
> requirements:
> ```
> click==7.1.2
> greenlet==1.1.2
> msgpack==1.0.2
> pynvim==0.4.3
> PyQt6==6.2.1
> pyqt6-plugins==6.1.0.2.2
> PyQt6-Qt6==6.2.1
> PyQt6-sip==13.1.0
> python-dotenv==0.19.2
> qt6-applications==6.1.0.2.2
> qt6-tools==6.1.0.1.2
> ```
> 
> I've also found a solution:
> ```
> $ git diff uiparser-old.py uiparser.py
> 62c62
> < align = getattr(QtCore.Qt, qt_align)
> ---
>> align = getattr(QtCore.Qt.AlignmentFlag, qt_align)
> ```
> 
> I had no idea where to put this but I was refered to this mailing list.

It will be fixed in the next snapshot.

Thanks,
Phil


More information about the PyQt mailing list