3

I am using Pyside2. I get the error

AttributeError: 'PySide2.QtCore.Qt.Alignment' object has no attribute 'testFlag'

for this piece of code

if (self.m_alignment.testFlag(Qt.AlignTop)):

The alignment is defined thus:

m_alignment = Qt.AlignTop | Qt.AlignRight

Is there something I am doing wrong? Or is there another way to check for an alignment flag in PySide2? Been stuck at this for some time.

nwagu
  • 532
  • 3
  • 17
  • It seems that PySide2 does not support QFlags, report it. – eyllanesc Feb 18 '19 at 19:02
  • 1
    Use bitwise AND: `if self.m_alignment & Qt.AlignTop`. There is no way to directly support `QFlags` in pyside/pyqt because it is a template class (which is specific to c++). – ekhumoro Feb 18 '19 at 21:51
  • It seems Qt is a special virtual module of either PyQt5 and/or PySide2.QtCore. See [this answer](https://stackoverflow.com/a/39317267/6501141) and that whole Q&A for more details. Not 100% sure that will directly fix this though. – LightCC Sep 06 '19 at 04:16

0 Answers0