Qt应用(qt5.14.2+vs2019)开发的应用字体因为显示缩放大于100%导致显示字体变大从而使QTableWidget变得臃肿。虽然设置QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);可以改变,但会导致整个窗口放大,使得显示区域不够用,经过测试我采用通过DPI计算字体大小的方法,这样不用改变窗体大小还能使得显示效果比较好看
m_pFontDPI.setPointSizeF(m_pFontDPI.pointSizeF() * qApp->primaryScreen()->logicalDotsPerInch() / qApp->screens().at(screenID)->logicalDotsPerInch());