Return type of QLineEdit:text
-
I wonder what QLineEdit.text returns?
https://doc.qt.io/qt-6/qlineedit.html#text-prop
It seems to be a QString. But based on that Issue it sometimes returns a
strinstance.How can I know?
Was there a change between Qt versions?
-
I wonder what QLineEdit.text returns?
https://doc.qt.io/qt-6/qlineedit.html#text-prop
It seems to be a QString. But based on that Issue it sometimes returns a
strinstance.How can I know?
Was there a change between Qt versions?
-
@buhtz
It has always been the case that PyQt and/or PySide convert freely betweenQStringand Pythonstrfor you. (PyQt at least does not have aQStringtype, IIRC.) Same with some other types....@JonB said in Return type of QLineEdit:text:
It has always been the case that PyQt and/or PySide convert freely between
QStringand Pythonstrfor you.Mhm... This confuses me much more. :D
In the Issue I was linking there is this line of Python code
diff_cmd = str( self.edit_command.text().toUtf8() )The reported error was "str doesn't have toUtf8()". The Issue was reported in 2018 and never fixed. But the application (incl. this
toUtf8()) was released more then once since 2018 and today.I can't explain that to myself. Maybe it is about a new Qt or PyQt version?
I am scared to break the code. And without knowing much more about it I have to do some real tests using older Linux distros if this would break anything.
-
@JonB said in Return type of QLineEdit:text:
It has always been the case that PyQt and/or PySide convert freely between
QStringand Pythonstrfor you.Mhm... This confuses me much more. :D
In the Issue I was linking there is this line of Python code
diff_cmd = str( self.edit_command.text().toUtf8() )The reported error was "str doesn't have toUtf8()". The Issue was reported in 2018 and never fixed. But the application (incl. this
toUtf8()) was released more then once since 2018 and today.I can't explain that to myself. Maybe it is about a new Qt or PyQt version?
I am scared to break the code. And without knowing much more about it I have to do some real tests using older Linux distros if this would break anything.
-
@JonB said in Return type of QLineEdit:text:
It has always been the case that PyQt and/or PySide convert freely between
QStringand Pythonstrfor you.Mhm... This confuses me much more. :D
In the Issue I was linking there is this line of Python code
diff_cmd = str( self.edit_command.text().toUtf8() )The reported error was "str doesn't have toUtf8()". The Issue was reported in 2018 and never fixed. But the application (incl. this
toUtf8()) was released more then once since 2018 and today.I can't explain that to myself. Maybe it is about a new Qt or PyQt version?
I am scared to break the code. And without knowing much more about it I have to do some real tests using older Linux distros if this would break anything.
@buhtz
Don't quote me on this, but Python hasencode('utf-8'), e.g. https://www.programiz.com/python-programming/methods/string/encode. Maybe you could do it that side? I have never understood encoding, despite asking many times and people explaining I just find it confusing! You may need an encoding expert who also does Python, maybe @SGaist will see this, if he doesn't mind he may be able to comment. -
@buhtz
Don't quote me on this, but Python hasencode('utf-8'), e.g. https://www.programiz.com/python-programming/methods/string/encode. Maybe you could do it that side? I have never understood encoding, despite asking many times and people explaining I just find it confusing! You may need an encoding expert who also does Python, maybe @SGaist will see this, if he doesn't mind he may be able to comment. -
Hi,
You likely have triggered something that either was never reported or a feature that was rarely used/triggered that it went unnoticed.
From memory, even in the PyQt4 time, the bindings would not provide QString not QByteArray. My guess is that the code was translated a bit too literally from a C++ example.