Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to successfully import files with mix use of PySide6 and PyQt6
Forum Updated to NodeBB v4.3 + New Features

Unable to successfully import files with mix use of PySide6 and PyQt6

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 3 Posters 2.7k Views
  • 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.
  • E explorer100

    This post is deleted!

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

    @explorer100
    What "tracebacks" and what "verbose"? You have Python debugger, print() statements, and Python lets you print a stack trace if that is what you mean. But debugger is most flexible. What is your "crash", how do you know it has "crashed", what message do you get? Have you run it under Python debugger? If Python itself is "crashing" that is different from your application "crashing".

    E 1 Reply Last reply
    0
    • JonBJ JonB

      @explorer100
      What "tracebacks" and what "verbose"? You have Python debugger, print() statements, and Python lets you print a stack trace if that is what you mean. But debugger is most flexible. What is your "crash", how do you know it has "crashed", what message do you get? Have you run it under Python debugger? If Python itself is "crashing" that is different from your application "crashing".

      E Offline
      E Offline
      explorer100
      wrote on last edited by explorer100
      #14

      @JonB just the application is crashing..

      I have a custom dialog that captures the accept and reject
      on reject i just issue self.done(QDialog.Rejected)

      the custom dialog is invoked as such:

      def newFile(self):
          from PyQt6.QtWidgets import QDialog
          dialog = NewProjectDialog()
          ret = dialog.exec()
          if (ret == QDialog.Accepted):
              print("User accepted.")
          elif ret == QDialog.Rejected:
              print("User rejected.")
          else :
              print("unknown return")
      

      it actually never returns from the exec()

      the NewProjectDialog has the below reject() function.

      def reject(self):
      
          from PyQt6.QtWidgets import QDialog
          print("will do the reject processing here")
          self.done(QDialog.Rejected)
      
      JonBJ 1 Reply Last reply
      0
      • E explorer100

        @JonB just the application is crashing..

        I have a custom dialog that captures the accept and reject
        on reject i just issue self.done(QDialog.Rejected)

        the custom dialog is invoked as such:

        def newFile(self):
            from PyQt6.QtWidgets import QDialog
            dialog = NewProjectDialog()
            ret = dialog.exec()
            if (ret == QDialog.Accepted):
                print("User accepted.")
            elif ret == QDialog.Rejected:
                print("User rejected.")
            else :
                print("unknown return")
        

        it actually never returns from the exec()

        the NewProjectDialog has the below reject() function.

        def reject(self):
        
            from PyQt6.QtWidgets import QDialog
            print("will do the reject processing here")
            self.done(QDialog.Rejected)
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #15

        @explorer100 said in Unable to successfully import files with mix use of PySide6 and PyQt6:

        @JonB just the application is crashing..

        What does this mean? I asked how you know it is "crashing". If you get neither a message nor some particular behaviour you would not even know it had "crashed"....

        You do not say whether you even get the message from your reject() or not. So we don't know whether it enters that but does not return from the exec() or whether it never enters the reject() in the first place. Please supply this sort of description with your questions, else we have to cross-examine you at every point because we cannot guess what you are/are not seeing.

        Replace your custom dialog with a plain QDialog and see if that works. Then subclass QDialog for a custom dialog and just override reject() and see how that goes. Then work up to your actual custom dialog.

        There is nothing special here. I would just call this standard debugging techniques. I don't know why you are seeing different behaviour between PySide & PyQt, I'm not going to have a magic answer, you have to do some investigation.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          explorer100
          wrote on last edited by explorer100
          #16

          sorry, not enough info.
          it actually enters the reject.
          with further checks.. if I remove the
          if (ret == QDialog.Accepted):
          and simply print ret, it actually prints the correct return!
          after that.. if I even I try to print out the value of QDialog.Accepted, as in:
          print("QDialog.Accepted",QDialog.Accepted)
          the application crashes!
          the window disappeared then this message is printed on the console
          Process finished with exit code -1073740791 (0xC0000409)

          JonBJ 1 Reply Last reply
          0
          • E explorer100

            sorry, not enough info.
            it actually enters the reject.
            with further checks.. if I remove the
            if (ret == QDialog.Accepted):
            and simply print ret, it actually prints the correct return!
            after that.. if I even I try to print out the value of QDialog.Accepted, as in:
            print("QDialog.Accepted",QDialog.Accepted)
            the application crashes!
            the window disappeared then this message is printed on the console
            Process finished with exit code -1073740791 (0xC0000409)

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

            @explorer100
            I'm afraid I don't know. To be clear, are you saying you have "crash" behaviour with one of PyQt vs PySide but not the other on same program? Which exact versions of each? Are you quite sure that nowhere do you mix the two now? Have you removed the matplot stuff for now?

            I don't think anyone will be able to tell you from what we have so far. You would need a minimal, standalone example if you want others to test. As I said earlier, I think you need to start from a plain QDialog, or one sub-classed but nothing other than reject() inside it, and test behaviour from there. Then gradually add in whatever you have in your real sub-classed code till something goes wrong.

            E 2 Replies Last reply
            0
            • JonBJ JonB

              @explorer100
              I'm afraid I don't know. To be clear, are you saying you have "crash" behaviour with one of PyQt vs PySide but not the other on same program? Which exact versions of each? Are you quite sure that nowhere do you mix the two now? Have you removed the matplot stuff for now?

              I don't think anyone will be able to tell you from what we have so far. You would need a minimal, standalone example if you want others to test. As I said earlier, I think you need to start from a plain QDialog, or one sub-classed but nothing other than reject() inside it, and test behaviour from there. Then gradually add in whatever you have in your real sub-classed code till something goes wrong.

              E Offline
              E Offline
              explorer100
              wrote on last edited by
              #18

              @JonB thanks.. I will do that.

              1 Reply Last reply
              0
              • JonBJ JonB

                @explorer100
                I'm afraid I don't know. To be clear, are you saying you have "crash" behaviour with one of PyQt vs PySide but not the other on same program? Which exact versions of each? Are you quite sure that nowhere do you mix the two now? Have you removed the matplot stuff for now?

                I don't think anyone will be able to tell you from what we have so far. You would need a minimal, standalone example if you want others to test. As I said earlier, I think you need to start from a plain QDialog, or one sub-classed but nothing other than reject() inside it, and test behaviour from there. Then gradually add in whatever you have in your real sub-classed code till something goes wrong.

                E Offline
                E Offline
                explorer100
                wrote on last edited by explorer100
                #19

                @JonB
                wow ... just figured out the issue...
                I needed to have the full path of:
                QDialog.DialogCode.Accepted
                and QDialog.DialogCode.Rejected

                rather than just QDialog.Accepted/Rejected.

                Is that a difference between the two environments of just a setting?

                JonBJ 1 Reply Last reply
                0
                • E explorer100

                  @JonB
                  wow ... just figured out the issue...
                  I needed to have the full path of:
                  QDialog.DialogCode.Accepted
                  and QDialog.DialogCode.Rejected

                  rather than just QDialog.Accepted/Rejected.

                  Is that a difference between the two environments of just a setting?

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

                  @explorer100
                  For Python at Qt5 all (most) Qt enumeration types were just defined at "the top level", be that Qt or more specialized ones like QDialog. At Qt6 they were moved to lower-level, more specific areas dependent on their usage, like QDialog.DialogCode here, there are many other cases elsewhere in the Qt classes. Any code or examples you may come across which used such types/constants needs changing from 5 to 6. You are not the first person to fall foul of this.

                  This ought affect PyQt6 and PySide6 equally, I'm not sure if you are finding a difference. Usually you get a runtime error since the old symbol is not defined. I don't know about your case. You were "unlucky" to come across this issue so early in your attempts. If you have old code or examples look out for such enumerations which need upgrading.

                  E 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @explorer100
                    For Python at Qt5 all (most) Qt enumeration types were just defined at "the top level", be that Qt or more specialized ones like QDialog. At Qt6 they were moved to lower-level, more specific areas dependent on their usage, like QDialog.DialogCode here, there are many other cases elsewhere in the Qt classes. Any code or examples you may come across which used such types/constants needs changing from 5 to 6. You are not the first person to fall foul of this.

                    This ought affect PyQt6 and PySide6 equally, I'm not sure if you are finding a difference. Usually you get a runtime error since the old symbol is not defined. I don't know about your case. You were "unlucky" to come across this issue so early in your attempts. If you have old code or examples look out for such enumerations which need upgrading.

                    E Offline
                    E Offline
                    explorer100
                    wrote on last edited by
                    #21

                    @JonB Thanks Jon for the clarification.
                    For me, using PySide6.. the enumeration was ok while specifying the top level. I should have made another connection with a previous issue where I couldn't specify Qmessage.Information anymore. After discovering this, I changed it to QMessageBox.Icon.Information and all is well.

                    Thanks again for your support.

                    By the way.. the matplotlib interface now also looks like it might work with all using PyQt6.
                    will keep you posted. thanks again.

                    JonBJ 1 Reply Last reply
                    0
                    • E explorer100

                      @JonB Thanks Jon for the clarification.
                      For me, using PySide6.. the enumeration was ok while specifying the top level. I should have made another connection with a previous issue where I couldn't specify Qmessage.Information anymore. After discovering this, I changed it to QMessageBox.Icon.Information and all is well.

                      Thanks again for your support.

                      By the way.. the matplotlib interface now also looks like it might work with all using PyQt6.
                      will keep you posted. thanks again.

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

                      @explorer100
                      Somebody, somewhere did write some sort of Python upgrade script to find and replace all the occurrences of the old symbols with the new ones. I don't know how good it is, but maybe it comes with a list of those which need changing you can look through.

                      I know I have referred to it in my posts here, but that was a long time ago. Whether I can find it again I don't know....

                      Oh, it's at https://stackoverflow.com/questions/72086632/migrating-to-qt6-pyqt6-what-are-all-the-deprecated-short-form-names-in-qt5. For PyQt5->6. There's a script to copy or a Py package to fetch. Or there's https://github.com/qutebrowser/qutebrowser/issues/5904#issuecomment-736792450. It seems they look through files supplied with PyQt rather than having a hard-coded list you could look at.

                      1 Reply Last reply
                      1

                      • Login

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