每当我尝试使用上一个代码块中的函数更改QTextEdit小部件的字体时,程序会立即崩溃并显示错误代码1。可能的原因是什么?
self.font = QFont("Arial")
...
self.text_edit = QTextEdit()
self.setCentralWidget(self.text_edit)
self.text_edit.setCurrentFont(self.font)
...
def aFont(self):
previous_font = self.font
self.font = QFontDialog().getFont(previous_font)
if self.font != previous_font:
self.text_edit.selectAll()
self.text_edit.setCurrentFont(self.font)
self.font = QFontDialog().getFont(previous_font)[0]
- user5413945