@MrAWD said in TypeError: __init__() missing 1 required positional argument: 'item':
TypeError: __init__() missing 1 required positional argument: 'item'
Well, I tried and PyQt6 reports same error. So this is not a PySide-only issue. But the PyQt6 gives a surprising clue:
jon@ubuntu-22:~/QtTests/PyQt$ python3 multiinherit.py
Traceback (most recent call last):
File "/home/jon/QtTests/PyQt/multiinherit.py", line 21, in <module>
win = MyWindow()
^^^^^^^^^^
File "/home/jon/QtTests/PyQt/multiinherit.py", line 16, in __init__
self.label = myClass("item")
^^^^^^^^^^^^^^^
File "/home/jon/QtTests/PyQt/multiinherit.py", line 10, in __init__
QLineEdit.__init__(self, parent)
TypeError: HelperClass.__init__() missing 1 required positional argument: 'item'
So although the error is shown beneath QLineEdit.__init__(self, parent) and PySide6 just says __init__() missing 1 required positional, PyQt6 says
HelperClass.__init__() missing 1 required positional
So it is complaining about HelperClass.__init__() not QLineEdit.__init__()....
I am not a regular Python dev so I will leave it at that.
UPDATE
On a whim/hunch, I tried changing the order of your inheritance to:
class myClass(HelperClass, QLineEdit)
Lo and behold, this works fine under both PySide & PyQt!
Now, it may be you were getting away with something which ought never to have worked on old PySide2. In C++ if you want to multi-inherit from a QObject type and a non-QObject type (not allowed to multi-inherit from QObject publicly) you must place the QObject one first in the list, to keep moc happy (https://doc.qt.io/qt-6/moc.html#multiple-inheritance-requires-qobject-to-be-first). To be fair, that is exactly what you non-working original did. I am finding the opposite is required to keep PyQt6/PySide6 happy here!
Check that with the re-arranged order everything else, especially the QLineEdit functionality/signals, work.
If so, my finding is that the reverse of what C++/moc wants is required for Py...! Go figure :)
P.S.
The error might have some relationship to https://forum.qt.io/post/755209
We have hit this issue too. PySide 6.5.0 appears to use the signature of the last super-class that is initialised for both of them.
I know you are not using super(), but when it goes wrong in your original order maybe this is related to the "using the last signature encountered". Or, you might want to look at Christian Tismer's answer in https://bugreports.qt.io/browse/PYSIDE-2294 where he suggests combining the two separate __init__()s into a single
super().__init__(a_value=a_value, b_value=b_value)
You might also report your original code as a "bug" to the PySide folks and see what they have to say. Though the fact that it behaves the same as PyQt may indicate it is not their problem.