[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: PyQt6: QBoxLayout.setAlignment(Qt.AlignmentFlag) raises TypeError
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2021-04-26 9:40:17
Message-ID: 0fd465a51ad1913475e343796c50e74e () riverbankcomputing ! com
[Download RAW message or body]

On 26/04/2021 10:03, Ales Erjavec wrote:
> Hi,
> 
> Trying to set an alignment on a QBoxLayout raises a TypeError:
> ```
> from PyQt6.QtCore import Qt
> from PyQt6.QtWidgets import QApplication, QWidget, QHBoxLayout
> 
> app = QApplication([])
> 
> lay = QHBoxLayout()
> lay.setAlignment(Qt.AlignmentFlag.AlignLeft)   # << error
> ```
> 
> The error:
> ```
> TypeError: arguments did not match any overloaded call:
>   setAlignment(self, QWidget, Qt.AlignmentFlag): argument 1 has
> unexpected type 'AlignmentFlag'
>   setAlignment(self, QLayout, Qt.AlignmentFlag): argument 1 has
> unexpected type 'AlignmentFlag'
> ```
> The two listed overloads are from QLayout implementation but the
> intended call is for
> the base QLayoutItem.setAlignment.
> 
> In PyQt5 this worked as evident by the QHBoxLayout.setAlignment 
> docstring:
> ```
> setAlignment(self, QWidget, Union[Qt.Alignment, Qt.AlignmentFlag]) -> 
> bool
> setAlignment(self, QLayout, Union[Qt.Alignment, Qt.AlignmentFlag]) -> 
> bool
> setAlignment(self, Union[Qt.Alignment, Qt.AlignmentFlag])
> ```

Fixed in the next snapshot.

Thanks,
Phil
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic