Open RachelKLowe opened 6 years ago
Thanks @KennethLowe, seems like a simple misaligned member in PySide2.
What I'd suggest is done is to unify them like this.
from Qt import QtCompat
QtCompat.QDate.toPyDate()
Such that this new QDate
would represent a compatibility wrapper around the Qt 4 and Qt 5 versions. We can't (shouldn't) add it to the original QDate
as it would mean (1) monkey patching and (2) leaving the old one behind and nearby, running the risk of either intermixing them in code or using the wrong one.
Have a look at adding this to the _compatibility_members
dictionary, and see whether it produces the results you're looking for. Then a PR would trigger the automatic tests and hopefully solve the issue, then I'd be able to merge.
Hello, we are using Qt.py to help with our transition from PyQt4 to PySide2 and I've run into some problems with QDate objects. I have a dialog that needs to be able to function in PyQt4 in one environment, and in PySide2 inside of Maya 2018. It is using a QDateEdit, QDateEdit.date() returns a QDate, but in PyQt4 we need to call QDateEdit.date().toPyDate() to get a datetime object back and in PySide2 we need to call QDateEdit.date().toPython().
I tried handling this in QtSiteConfig.py with the following update_compatibility_members method:
The code is executing, print statements inside of the method are visible, but when my bindings are PyQt4 QDate objects still do not have a toPython method on them.
Any help to get this working site wide would be greatly appreciated. For now we are just using hasattr to check for toPython on the QDate, and doing QDate.toPython = QDate.toPyDate if it isn't find, but it would be nice to fix it centrally. Thanks!
Kenny