PyQt6: setting enum values to properties using keyword args in init.
Phil Thompson
phil at riverbankcomputing.com
Sat Jan 16 16:49:21 GMT 2021
On 15/01/2021 17:23, alan moore wrote:
> Hello all,
>
> I'm starting the process of porting some PyQt5 code to PyQt6, and step
> one is dealing with the namespacing of enums.
>
>
> In PyQt5 I could specify certain property values as keyword arguments,
> e.g.:
>
>
> tab_widget = QtWidgets.QTabWidget(
>
> tabPosition=QtWidgets.QTabWidget.West,
>
> tabShape=QtWidgets.QTabWIdget.Triangular
>
> )
>
>
> So converting to PyQt6, I figured I just need to fix the path of the
> enum values:
>
>
> tab_widget = QtWidgets.QTabWidget(
>
> tabPosition=QtWidgets.QTabWidget.TabPosition.West,
>
> tabShape=QtWidgets.QTabWIdget.TabShape.Triangular
>
> )
>
>
> However, this gives an error:
>
>
> TypeError: unable to convert a Python 'TabPosition' object to a
> C++ 'TabPosition' instance
>
> (and likewise with TabShape if I remove the tabPosition argument).
>
>
> I *can* set these after the widget is created using the setter:
>
>
> tab_widget.setTabPosition(QtWidgets.QTabWidget.TabPosition.West)
>
>
> SO I guess this is my long-winded way of asking if this is a bug, if
> I'm just doing it wrong, or if keyword property arguments are no
> longer supported. Thanks!
A bug - should be fixed the next snapshot.
Thanks,
Phil
More information about the PyQt
mailing list