AnonymCode
AnonymCode

Reputation: 676

Load a .ttf file as a font in PyQt6

font_db = QFontDatabase()
font_id = font_db.addApplicationFont("test.ttf")

This is deprecated in PyQt6 and gives the warning

 DeprecationWarning: QFontDatabase.QFontDatabase() is deprecated
  font_db = QFontDatabase()

what to use instead of QFontDatabase to load a font from a .ttf file.

Upvotes: 1

Views: 1239

Answers (1)

AnonymCode
AnonymCode

Reputation: 676

As commented by musicamante calling the class methods as static functions works.
So instead of this :

font_db = QFontDatabase()
font_id = font_db.addApplicationFont('test.ttf')

It should be done like this :

QFontDatabase.addApplicationFont('test.ttf')

Upvotes: 1

Related Questions