回帖:原书里面的 QTimer.singleShot(5000,self.message.clear)
报错显示:
QTimer.singleShot(5000,self.message.clear)AttributeError: 'str' object has no attribute 'clear'? self.message 里没有clear 这个属性吗?
另外 如果self.message = str # self.message = str 为什么不能识别成字符串类型?
if self.message:
painter.drawText(self.rect(),
Qt.AlignBottom|Qt.AlignHCenter,
self.message)# 这里的self.message 就会报错如下:
self.message)
TypeError: arguments did not match any overloaded call:
drawText(self, Union, str): argument 1 has unexpected type 'QRect'
drawText(self, QRectF, int, str): argument 1 has unexpected type 'QRect'
drawText(self, QRect, int, str): argument 3 has unexpected type 'type'
drawText(self, QRectF, str, option: QTextOption = QTextOption()): argument 1
has unexpected type 'QRect'
drawText(self, QPoint, str): argument 1 has unexpected type 'QRect'
drawText(self, int, int, int, int, int, str): argument 1 has unexpected type
'QRect'
drawText(self, int, int, str): argument 1 has unexpected type 'QRect'
定义成下面的单引号才不会出现上面的错误,这是为啥? 高手请不吝赐教,谢谢!
self.message = ''