Skip to content Skip to sidebar Skip to footer

'qstring' Object Does Not Support Item Assignment Python

self.date = QtCore.QDate.currentDate() self.time = QtCore.QTime.currentTime() self.updateTime = QtCore.QString(self.time.toString('hh:mm:ss AP')) if ((self.time.second() % 2) == 0

Solution 1:

Your problem is that you cannot change the the QString by item assignment (a[2] = ' '); you get a TypeError whenever you try to do something to an object that isn't allowed. You have to create a new string and assign it to the variable. So, replace the line

self.updateTime[2]= ' '

with the following

self.updateTime = self.updateTime[:2] + ' ' +self.updateTime[3:]

Post a Comment for "'qstring' Object Does Not Support Item Assignment Python"