Unable to successfully import files with mix use of PySide6 and PyQt6
-
This post is deleted!
-
This post is deleted!
@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". -
@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".@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)
-
@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)
@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 theexec()
or whether it never enters thereject()
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 subclassQDialog
for a custom dialog and just overridereject()
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.
-
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) -
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)@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 thanreject()
inside it, and test behaviour from there. Then gradually add in whatever you have in your real sub-classed code till something goes wrong. -
@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 thanreject()
inside it, and test behaviour from there. Then gradually add in whatever you have in your real sub-classed code till something goes wrong.@JonB thanks.. I will do that.
-
@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 thanreject()
inside it, and test behaviour from there. Then gradually add in whatever you have in your real sub-classed code till something goes wrong.@JonB
wow ... just figured out the issue...
I needed to have the full path of:
QDialog.DialogCode.Accepted
and QDialog.DialogCode.Rejectedrather than just QDialog.Accepted/Rejected.
Is that a difference between the two environments of just a setting?
-
@JonB
wow ... just figured out the issue...
I needed to have the full path of:
QDialog.DialogCode.Accepted
and QDialog.DialogCode.Rejectedrather than just QDialog.Accepted/Rejected.
Is that a difference between the two environments of just a setting?
@explorer100
For Python at Qt5 all (most) Qt enumeration types were just defined at "the top level", be thatQt
or more specialized ones likeQDialog
. At Qt6 they were moved to lower-level, more specific areas dependent on their usage, likeQDialog.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.
-
@explorer100
For Python at Qt5 all (most) Qt enumeration types were just defined at "the top level", be thatQt
or more specialized ones likeQDialog
. At Qt6 they were moved to lower-level, more specific areas dependent on their usage, likeQDialog.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.
@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. -
@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.@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.