I'm doing a small application in Pyqt4 to understand the operation.
In a given part, I'm using a callback function to display a QLabel
text that is typed in QtextEdit
.
This text should be trimmed (remove spaces before and after the string).
When I tried to use the strip
function present in str
of Python the following error occurred:
AttributeError: 'QString' object has no attribute 'strip'
As I understand, in PyQt, the string is not an object str
, but QString
and QString
does not have the strip
method.
In this case, what can I do to get my treated string?
Code:
def onButtonOkClicked(self):
def setText():
text = self.line.toPlainText().strip();
self.label.setText(text)
QtCore.QObject.connect(self.buttonOk, QtCore.SIGNAL("clicked()"), setText)