QSizePolicy.PolicyFlag broken

Phil Thompson phil at riverbankcomputing.com
Thu Jan 6 16:23:10 GMT 2022


On 06/01/2022 03:22, Kovid Goyal wrote:
> python -c 'from PyQt6.QtWidgets import QSizePolicy;
> QSizePolicy(QSizePolicy.PolicyFlag.ExpandFlag)'
>               
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> TypeError: arguments did not match any overloaded call:
>   QSizePolicy(): argument 1 has unexpected type 'PolicyFlag'
>   QSizePolicy(QSizePolicy.Policy, QSizePolicy.Policy, type:
> QSizePolicy.ControlType = QSizePolicy.DefaultType): argument 1 has
> unexpected type 'PolicyFlag'
> 
> python -c 'from PyQt6.QtWidgets import QSizePolicy;
> QSizePolicy(QSizePolicy.PolicyFlag.ExpandFlag |
> QSizePolicy.PolicyFlag.ShrinkFlag)'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> TypeError: unsupported operand type(s) for |: 'PolicyFlag' and 
> 'PolicyFlag'
> 
> And QWidget::setSizePolicy() doesnt take policyflags either.

The problem here is that the C++ API is broken so that you can't use 
"non-standard" combinations of PolicyFlag without using explicit casts.

Are you using combinations of PolicyFlag that aren't defined by the 
Policy enum?

Phil


More information about the PyQt mailing list