[PySide] problem with __init__ and QObject
Cristián Maureira-Fredes
Cristian.Maureira-Fredes at qt.io
Tue Mar 19 00:31:00 CET 2024
Hello Trevor,
For that specific case, I'd recommend you
call the A constructor first:
from PySide6.QtCore import QObject
class A:
def __init__(self, val=1):
print(f"A {val}")
class B(A, QObject):
def __init__(self):
A.__init__(self, val=2)
QObject.__init__(self)
bb=B()
which prints
A 2
Cheers
On 18/03/2024 20:31, Clarke, Trevor wrote:
> *
> Ball Aerospace is now part of BAE Systems, Inc. with a new sector name –
> Space & Mission Systems. Learn more here.
> <https://www.baesystems.com/en-us/our-company/inc-businesses/space-and-mission-systems>*
>
> from PySide6.QtCore import QObject
>
> class A:
>
> def __init__(self, val=1):
>
> print(f"A {val}")
>
> class B(QObject, A):
>
> def __init__(self):
>
> QObject.__init__(self)
>
> A.__init__(self, val=2)
>
> bb=B()
>
> output is
>
> A 1
>
> A 2
>
> How do I correctly call the A init only once with args?
>
> **
>
> *Trevor Clarke***
>
> /Senior Software Engineer/
>
> Space & Mission Systems Sector, BAW Systems, Inc.
>
> T: +1-937-416-7167 | E: trevor.clarke at ballaerospace.com
>
> Fairborn, OH | Pronouns: He/Him
>
> baesystems.com
>
>
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> https://lists.qt-project.org/listinfo/pyside
--
Dr. Cristián Maureira-Fredes
Senior R&D Manager
The Qt Company GmbH
Erich-Thilo-Str. 10
D-12489 Berlin
Geschäftsführer: Mika Pälsi,
Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
More information about the PySide
mailing list