简体   繁体   中英

Add a custom font in Qt

There's anyway to add a custom font (Such as Console Font) to Qt? How? And how do we set it to a Text Editor (QPlainTextEdit, QTextEdit, etc)?

Thanks

Qt uses your window system as a font provider. You can find out all the fonts available by using the QFontDatabase class. Anyway, it is possible to add a specific custom font for your application to use using QFontDatabase::addApplicationFont from C++ (available under X11 only if fontconfig is available) or using the FontLoader component in QML.

For QTextEdit you can use this and for QPlainTextEdit you might try the font property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM