Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. TypeError with PySide 6.5.0 for multiple inheritance of MainWindow
Forum Updated to NodeBB v4.3 + New Features

TypeError with PySide 6.5.0 for multiple inheritance of MainWindow

Scheduled Pinned Locked Moved Solved Qt for Python
28 Posts 5 Posters 11.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S StarterKit

    @JonB said in TypeError with PySide 6.5.0 for multiple inheritance of MainWindow:

    For the architecture of this particular logger case. Since you have to derive from logging.Handler, why don't you encapsulate the QPlainTextEdit in your class instead of multiple-inheriting from it? My initial thought is that would be preferable. Then you would not multiple-inherit and you wouldn't have the current problem, whatever it is.

    Finally I decided to encaplusate logging.Handler in my class and now I like it more than before :)
    The bug was confirmed in PySide and to be corrected in future versions but everything works good without multiple inheritance.

    Also initial code was not ideal and was different from Qt recommendations.

    So, with both things changed I have my code up and running again.

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #17

    @StarterKit said in TypeError with PySide 6.5.0 for multiple inheritance of MainWindow:

    Finally I decided to encaplusate logging.Handler in my class and now I like it more than before :)

    That is indeed the best, but earlier you said

    But your handler should be a descendant of logging.Handler.

    Anyway, sounds good :)

    S 1 Reply Last reply
    0
    • JonBJ JonB

      @StarterKit said in TypeError with PySide 6.5.0 for multiple inheritance of MainWindow:

      Finally I decided to encaplusate logging.Handler in my class and now I like it more than before :)

      That is indeed the best, but earlier you said

      But your handler should be a descendant of logging.Handler.

      Anyway, sounds good :)

      S Offline
      S Offline
      StarterKit
      wrote on last edited by
      #18

      @JonB said in TypeError with PySide 6.5.0 for multiple inheritance of MainWindow:

      That is indeed the best, but earlier you said

      I thought one more time about it and decided that there is a better desing option possible :) Not a big change but I moved 2 more methods inside my class and it looks good after all :)

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jonton
        wrote on last edited by
        #19

        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. The example we have is:

            def __init__(self, rootDataModel, parent):
                super(QtCore.QObject, self).__init__(self)
                StateSource.__init__(self, parent, "model")
        

        This results in a runtime error of:

            QtCore.QObject.__init__(self)
        TypeError:__init__() missing 2 required positional arguments: 'parent' and 'name'
        

        If I reverse the order of initialisation to:

            def __init__(self, rootDataModel, parent):
                StateSource.__init__(self, parent, "model")
                super(QtCore.QObject, self).__init__(self)
        

        Then the error reports that the StateSource initialiser only should have a single parameter.

        J 1 Reply Last reply
        0
        • J jonton

          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. The example we have is:

              def __init__(self, rootDataModel, parent):
                  super(QtCore.QObject, self).__init__(self)
                  StateSource.__init__(self, parent, "model")
          

          This results in a runtime error of:

              QtCore.QObject.__init__(self)
          TypeError:__init__() missing 2 required positional arguments: 'parent' and 'name'
          

          If I reverse the order of initialisation to:

              def __init__(self, rootDataModel, parent):
                  StateSource.__init__(self, parent, "model")
                  super(QtCore.QObject, self).__init__(self)
          

          Then the error reports that the StateSource initialiser only should have a single parameter.

          J Offline
          J Offline
          jonton
          wrote on last edited by
          #20

          @jonton

          This makes me think it's a new bug that has been introduced into the handling of multiple inheritance in PySide.

          I don't know enough about the inner workings of PySide, perhaps someone on this forum can shed some light on it?

          JonBJ 1 Reply Last reply
          0
          • J jonton

            @jonton

            This makes me think it's a new bug that has been introduced into the handling of multiple inheritance in PySide.

            I don't know enough about the inner workings of PySide, perhaps someone on this forum can shed some light on it?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #21

            @jonton
            There was some "fix" for 6.5.0/6.6.0 in https://bugreports.qt.io/browse/PYSIDE-2294, though I don't know what was "fixed" exactly.
            Have you read that one? Should you comment there?

            J 1 Reply Last reply
            0
            • JonBJ JonB

              @jonton
              There was some "fix" for 6.5.0/6.6.0 in https://bugreports.qt.io/browse/PYSIDE-2294, though I don't know what was "fixed" exactly.
              Have you read that one? Should you comment there?

              J Offline
              J Offline
              jonton
              wrote on last edited by
              #22

              Thanks @JonB

              That does sound like the same issue, but as you say it's not clear in the discussion whether there is actually a fix in 6.6.0 or not?

              I'll check in with them there.

              Cheers,

              Jon

              JonBJ 1 Reply Last reply
              0
              • J jonton

                Thanks @JonB

                That does sound like the same issue, but as you say it's not clear in the discussion whether there is actually a fix in 6.6.0 or not?

                I'll check in with them there.

                Cheers,

                Jon

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #23

                @jonton
                It is deffo the same issue! :) It was reported against 6.4. I don't understand because I read it as it was "fixed" in both 6.5.0 & 6.6.0, whatever fixing in "both" means, but I think you are saying you are having a problem in 6.5. I don't know whether that is the original problem OR they did some fix for that which you have, but now you have/that has introduced a (new?) problem with your super() case.

                J 1 Reply Last reply
                0
                • JonBJ JonB

                  @jonton
                  It is deffo the same issue! :) It was reported against 6.4. I don't understand because I read it as it was "fixed" in both 6.5.0 & 6.6.0, whatever fixing in "both" means, but I think you are saying you are having a problem in 6.5. I don't know whether that is the original problem OR they did some fix for that which you have, but now you have/that has introduced a (new?) problem with your super() case.

                  J Offline
                  J Offline
                  jonton
                  wrote on last edited by jonton
                  #24

                  I'm certainly having the problem in 6.5.0, whereas the code works in 6.4.3 correctly.

                  It looks like the change that came into 6.5.0 was this:

                  https://github.com/pyside/pyside-setup/commit/e8095467f7d0332cc0987e7c541de9906e19fece

                  And this has caused the regression?

                  JonBJ 1 Reply Last reply
                  0
                  • J jonton

                    I'm certainly having the problem in 6.5.0, whereas the code works in 6.4.3 correctly.

                    It looks like the change that came into 6.5.0 was this:

                    https://github.com/pyside/pyside-setup/commit/e8095467f7d0332cc0987e7c541de9906e19fece

                    And this has caused the regression?

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #25

                    @jonton
                    I would not begin to know the implications of the changes you see.

                    It sounds like:

                    • There was a problem with multiple inheritance at 6.4 which they fixed at 6.5, or they just changed/improved it, per the changes.

                    • Now at 6.5 that may be fixed/improved, but other cases, such as yours and @StarterKit's, go wrong, where they used to be OK at 6.4.

                    I do not truly understand the discussion in https://bugreports.qt.io/browse/PYSIDE-2294 or what the conclusion was. You may need to post there, or raise a new issue.

                    One thing: I see you use super(QtCore.QObject, self).__init__(self) in both your cases. But @SGaist wrote

                    This is wrong, self shall not be part of the arguments passed to the function called when using super.
                    super().init(parent=parent)

                    So is not that the issue?

                    At this point I am passing here, as it's becoming a Python issue I am not sufficiently familiar with.

                    J 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @jonton
                      I would not begin to know the implications of the changes you see.

                      It sounds like:

                      • There was a problem with multiple inheritance at 6.4 which they fixed at 6.5, or they just changed/improved it, per the changes.

                      • Now at 6.5 that may be fixed/improved, but other cases, such as yours and @StarterKit's, go wrong, where they used to be OK at 6.4.

                      I do not truly understand the discussion in https://bugreports.qt.io/browse/PYSIDE-2294 or what the conclusion was. You may need to post there, or raise a new issue.

                      One thing: I see you use super(QtCore.QObject, self).__init__(self) in both your cases. But @SGaist wrote

                      This is wrong, self shall not be part of the arguments passed to the function called when using super.
                      super().init(parent=parent)

                      So is not that the issue?

                      At this point I am passing here, as it's becoming a Python issue I am not sufficiently familiar with.

                      J Offline
                      J Offline
                      jonton
                      wrote on last edited by
                      #26

                      @JonB

                      Thanks for all the help with this, it's been invaluable. I found the root cause of our problem. The order that the base classes are inherited in affects the Method Resolution Order, which confuses the new system.

                      I think it points to an error in PySide 6.5.0, but I don't have enough knowledge of the inner workings of Python and PySide to make a call on this. I'll put a note on the issue page that you pointed to.

                      The PR to fix this in USD is here, which goes into an explanation of the issue:

                      https://github.com/PixarAnimationStudios/USD/pull/2392

                      JonBJ 1 Reply Last reply
                      1
                      • J jonton

                        @JonB

                        Thanks for all the help with this, it's been invaluable. I found the root cause of our problem. The order that the base classes are inherited in affects the Method Resolution Order, which confuses the new system.

                        I think it points to an error in PySide 6.5.0, but I don't have enough knowledge of the inner workings of Python and PySide to make a call on this. I'll put a note on the issue page that you pointed to.

                        The PR to fix this in USD is here, which goes into an explanation of the issue:

                        https://github.com/PixarAnimationStudios/USD/pull/2392

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #27

                        @jonton said in TypeError with PySide 6.5.0 for multiple inheritance of MainWindow:

                        I'll put a note on the issue page that you pointed to.

                        Please do so. I don't know whether they will say it is a 6.5.0 issue or whether they will say your code is wrong/the behaviour you see is correct.

                        1 Reply Last reply
                        0
                        • S StarterKit

                          Hi all,
                          It appears I got a problem after PySide upgrade from 6.4.3 to 6.5.0.
                          Here is a minimal example - it does nothing special, just displays a window and a label in it. The structure of the code is similar to the one I use in real project where UI is created with help of Qt Designer generated files.
                          This code works fine with PySide 6.4.3, but with PySide 6.5.0 it raises an error.
                          The error:

                          window = MainWindow()
                                       ^^^^^^^^^^^^^^^^^
                          File "main.py", line 11, in __init__
                            QMainWindow.__init__(self, parent=None)
                          TypeError: object.__init__() takes exactly one argument (the instance to initialize)
                          

                          The code:

                          from PySide6.QtWidgets import QApplication, QMainWindow, QLabel
                          
                          class Ui_X_MainWindow(object):
                              def setupUi(self, MainWindow):
                                  MainWindow.resize(400, 300)
                                  self.lbl = QLabel(self)
                          
                          class MainWindow(QMainWindow, Ui_X_MainWindow):
                              def __init__(self):
                                  QMainWindow.__init__(self, parent=None)
                                  self.setupUi(self)
                                  self.lbl.setText("XXX")
                          
                          app = QApplication([])
                          window = MainWindow()
                          window.show()
                          app.exec()
                          
                          Q Offline
                          Q Offline
                          qqiq
                          wrote on last edited by
                          #28

                          I have same problem. The problem for me is that the PySide6.5.0 I installed does not match the python version I used. My python version is 3.10, while the python version for installed PySide is 3.7 when using pip to install.

                          Collecting PySide6
                          Using cached PySide6-6.5.0-cp37-abi3-win_amd64.whl (7.2 kB)

                          No idea why it use 3.7

                          1 Reply Last reply
                          0
                          • Pl45m4P Pl45m4 referenced this topic on

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved