1
Windows 10을 실행 중이고 PyQt5 (아나콘다의 Python 3.6, Qt5.6)를 사용 중입니다. 저는 두 대의 모니터를 가지고 있는데, 하나의 HD는 100 %로 조정되고 다른 하나는 4K 모니터가 150 %로 조정됩니다. 아래에 간단한 GUI 예제가 있습니다. 제목 표시 줄을 제외한 모든 것은 비늘입니다. 내가 어떻게 고칠 수 있는지 궁금해. 아래 두 가지 해상도의 이미지를 참조하십시오.윈도우 타이틀이 모니터 당 PyQt5를 확장하지 않음 DPI
import sys
from PyQt5 import QtGui, QtCore, QtWidgets
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
app = QtWidgets.QApplication([])
window = QtWidgets.QMainWindow()
window.setWindowTitle("Hello World")
fileMenu = QtWidgets.QMenu("File", window)
longMenu = QtWidgets.QMenu("Long Menu Title", window)
window.menuBar().addMenu(fileMenu)
window.menuBar().addMenu(longMenu)
window.show()
sys.exit(app.exec_())
아래 답변에 대한 응답 :
답변 아래의 메뉴 글꼴을 변경하지만 윈도우 제목 표시 줄에 영향을주지 않습니다에 따라, window.font() 속성을 설정 세례반. 다음 코드는 아래 이미지의 결과를 생성 : 아래 코드와 같이
import sys
from PyQt5 import QtGui, QtCore, QtWidgets
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
app = QtWidgets.QApplication([])
window = QtWidgets.QMainWindow()
window.setWindowTitle("Hello World")
fileMenu = QtWidgets.QMenu("File", window)
longMenu = QtWidgets.QMenu("Long Menu Title", window)
window.menuBar().addMenu(fileMenu)
window.menuBar().addMenu(longMenu)
font = window.font()
font.setPointSize(12)
window.setFont(font) # set font here
window.show()
sys.exit(app.exec_())
는 나는()'가족을 변경하지 않는 글꼴 = window.font'에()''글꼴 = QtGui.QFont을 변경하는 것이 가장 좋습니다 생각합니다. – eyllanesc
제안 된대로 수정 됨 :-) – ZF007
'window.QFont()'는 window.font()와 다릅니다 – eyllanesc