Unable to successfully import files with mix use of PySide6 and PyQt6
-
@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.