Recently, we have encountered a phenomenon that running a good software on a higher resolution computer will lead to incomplete font display and occlusion by controls. Specific reasons can be inquired online, and solutions will be recorded here.
Two methods are recorded here. If the QT version used is later than 5.6.0, it can support high UU DPI, and the application can set this property; if not, it can set the adaptive font for the application.
if __name__ == "__main__": v_compare = QVersionNumber(5,6,0) V? Current,? = qversionnumber.fromstring (QT? Version? STR) if QVersionNumber.compare(v_current,v_compare) >=0 : Qapplication.setattribute (QT. AA? Enablehigh piscaling)? QT starts from 5.6.0 and supports high DPI app = QApplication(sys.argv) # else: app = QApplication(sys.argv) Font = qfont ("Tahoma") pointsize = font.pointSize() font.setPixelSize(pointsize*90/72) app.setFont(font) mymainwin = Mymainwindow() mymainwin.show() sys.exit(app.exec())
Be careful:The qapplication.setattribute (QT. AA? Enablehighdpiscaling) is before the QApplication project is created.