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

Damon Lynch damonlynch at gmail.com
Tue Mar 8 09:39:39 GMT 2016


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'


Damon
-- 
http://www.damonlynch.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160308/9794eea2/attachment.html>


More information about the PyQt mailing list