May 2019
Intermediate to advanced
542 pages
13h 37m
English
Qt provides a number of other convenient selection dialog boxes similar to the QFileDialog; one such dialog box is the QFontDialog, which allows users to select and configure various aspects of a text font.
Like the other dialog box classes, this is most easily used by calling a static method to display the dialog box and return the user's selection, in this case, the getFont() method.
Let's add a callback method to our MainWindow class to set the editor font:
def set_font(self): current = self.textedit.currentFont() font, accepted = qtw.QFontDialog.getFont(current, self) if accepted: self.textedit.setCurrentFont(font)
getFont takes the current font as an argument, which allows it to set the selected font to whatever is current ...
Read now
Unlock full access