[PyQt] Is this the supported PyQt5 way to reset a flag?

Phil Thompson phil at riverbankcomputing.com
Tue Mar 8 09:50:19 GMT 2016


On 8 Mar 2016, at 9:39 am, Damon Lynch <damonlynch at gmail.com> wrote:
> 
> 
> 
> On Tue, Mar 8, 2016 at 2:09 PM, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On 8 Mar 2016, at 6:29 am, Damon Lynch <damonlynch at gmail.com> wrote:
> >
> > The Qt 5 docs specify enum Qt::AlignmentFlag and flags Qt::Alignment.
> >
> > Obviously this is valid:
> >
> > layout.setAlignment(widget, Qt.AlignTop)
> >
> > But is this supported?
> >
> > layout.setAlignment(widget, Qt.AlignmentFlag())
> >
> > It has the effect of resetting the alignment flag, which is precisely what I want it to do.  Is that the supported way of resetting a flag? If this is already discussed in the docs please let me know as I've been unable to locate it.
> 
> Yes, or just pass 0. PyQt (for historical reasons) throws away much of the type safety that QFlags implements.
> 
> 
> 
> Passing 0 fails :
> TypeError: arguments did not match any overloaded call:
>   QLayout.setAlignment(QWidget, Qt.Alignment): argument 2 has unexpected type 'int'
>   QLayout.setAlignment(QLayout, Qt.Alignment): argument 1 has unexpected type 'QToggleView'
>   QLayout.setAlignment(Qt.Alignment): argument 1 has unexpected type 'QToggleView'

Whoops - shows you how much I know.

Phil


More information about the PyQt mailing list