I would like to request a memorandum and correction. The size of the widget is reproduced in almost the same way on any OS, but the font size is not the same. I wrote the code to adjust the font size between OSs, thinking that it might be related to the difference in DPI.
from PySide2.QtCore import QOperatingSystemVersion
from PySide2 import QtWidgets,QtGui
currentOsType = QOperatingSystemVersion.currentType()
if currentOsType == QOperatingSystemVersion.OSType.MacOS:
font.setPointSize(20)
return(font)
if currentOsType == QOperatingSystemVersion.OSType.Windows:
font.setPointSize(20/1.33333)
else:
print(currentOsType)
font.setPointSize(20/1.33333)
return(font)
1.3333 is derived from the numbers Mac72dpi and Windows96dpi. This is almost good in my environment, so I haven't investigated further.
Recommended Posts