pythonqt icon indicating copy to clipboard operation
pythonqt copied to clipboard

QString <-> Python conversion, null/None

Open gregor-anich-uibk opened this issue 4 years ago • 0 comments

Hello,

I use a custom wrapper to provide operators etc for a class. I also provide the py_toString function. Problem is if I return an empty string, then PythonQtInstanceWrapper_str returns the default ("%s (C++ Object %p)", typeName, wrapper->_wrappedPtr). I was wondering if it would be a good idea to convert a null QString to None and vice versa, but I think this could be a too invasive change breaking existing code, what do you think? Another option would probably be to make getStringFromObject in PythonQtInstanceWrapper.cpp return a "bool ok" to signal that an empty string was returned by the wrapper, and then not fallback to the default string.

Edit: I chose the second option, see commit bc70661

gregor-anich-uibk avatar Oct 20 '20 09:10 gregor-anich-uibk