(PyQt) Why can't I change the font of my QTextEdit widget?

Viewed 1167

Whenever I try to change the font of my QTextEdit widget using the function from the last codeblock, the program crashes instantly with code 1. What could be the reason of it?

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)
1 Answers
Related