PyQt5高清屏幕自适应设置 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

Qt Designer 设计界面:

PyQt5高清屏幕自适应设置 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

 

 在高清屏未设置AA_EnableHighDpiScaling的预览界面:布局字体控件尺寸上明显存在偏差.

 

PyQt5高清屏幕自适应设置 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

 

 设置了AA_EnableHighDpiScaling的预览界面:运行后,与designer界面一致

PyQt5高清屏幕自适应设置 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

 

from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox
from PyQt5.QtCore import Qt
from Ui_mainqt import Ui_MainWindow
 
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        self.iniConn()
 
if __name__ == __main__:
    import sys
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) 
    app = QApplication(sys.argv)
    formmain = MainWindow()
    formmain.show()
    sys.exit(app.exec_())

 

PyQt5高清屏幕自适应设置 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

上一篇:.Net Core中使用Dapper构建泛型仓储


下一篇:股票投资相关,移动平均线