python - PyQt5 中的字体无法正确显示
问题描述
我正在尝试在 Python 3.8 下使用 PyQt5 构建一个基本的 gui-Window。这是我正在使用的代码:
from PyQt5 import QtWidgets
from PyQt5 import QtGui
import sys
class Window(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle('Label')
self.setGeometry(1000,1000,1000,1000)
self.label_1 = QtWidgets.QLabel(self)
self.label_1.setText('Welcome to the App')
self.show()
# create pyqt5 App
App = QtWidgets.QApplication(sys.argv)
# create instance of Window
window = Window()
sys.exit(App.exec())
当我尝试运行它时收到以下错误消息(操作系统:Windows 10):
qt.qpa.fonts: Unable to enumerate family ' "Droid Sans Mono Dotted for Powerline" '
qt.qpa.fonts: Unable to enumerate family ' "Droid Sans Mono Slashed for Powerline" '
qt.qpa.fonts: Unable to enumerate family ' "Roboto Mono Medium for Powerline" '
qt.qpa.fonts: Unable to enumerate family ' "Ubuntu Mono derivative Powerline" '
标签也没有完全显示在我正在创建的窗口中。我已经尝试使用 Application.setFont("Arial") 方法将整个应用程序的字体设置为“Arial”,并通过以下方式直接设置标签的字体:
self.label_1.setFont(QtGui.QFont('Arial'))
这两个都没有改变我窗口中标签的外观。
解决方案
推荐阅读
- oracle - 使用聚合函数根据 MIN 时间戳过滤记录
- node.js - 节点 JS 函数未执行。可能是什么原因?
- objective-c - 如何在 Mac OS X 应用程序中从一个 NSViewcontroller 推送到另一个 NSViewcontroller?
- java - 有效地将最终结果放入地图中
- html - 我如何将下拉列表中的多个操作发布到节点 js?
- perl - Perl 并发症在“has ... => ...”上失败
- c# - Nonfactors MVC Grid 三元运算符失败
- c# - 如何将windows时区转换为moment js时区
- angular - Angular - 如何使用 WebAPI 端点而不将端点硬编码到 httpGet 方法中?
- reactjs - 使用带有 react-emotion 的嵌套伪 CSS 选择器