You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deftext(self):
""" Overridden base method to return the original unmodified text :returns: The original unmodified text """returnself.property("dayu_text")
defsetText(self, text):
""" Overridden base method to set the text on the label :param text: The text to set on the label """self.setProperty("dayu_text", text)
self._update_elided_text()
self.setToolTip(text)
在_update_elided_text方法中区分是否为html形式,若是则不使用省略模式
def_update_elided_text(self):
""" Update the elided text on the label """_font_metrics=self.fontMetrics()
text=self.property("dayu_text")
text=textiftextelse""# 检查文本是否包含 HTML 标签is_html=bool(re.search(r'<[^>]+>', text))
ifis_html:
# 如果文本包含 HTML 标签,直接设置富文本super(MLabel, self).setText(text)
else:
# 否则,使用省略模式设置文本_elided_text=_font_metrics.elidedText(text, self._elide_mode, self.width() -2*2)
super(MLabel, self).setText(_elided_text)
The text was updated successfully, but these errors were encountered:
20240729101900_rec_.mp4
可能的修改方式
把MLabel中的text和setText方法改为使用”dayu_text“,”dayu_text“保存完整文本,”text“保存显示文本
在_update_elided_text方法中区分是否为html形式,若是则不使用省略模式
The text was updated successfully, but these errors were encountered: