项目场景:
MSYS2 升级到 Qt6.7.0,发现显示故障,所有Qt6程序以及 QtCreator的SpinBox都显示不全,Combox的底色不对。
问题描述
2024年4月1日,pacman升级MSYS2后,Qt6遇到风格错误。如果使用官方的 Qt online installer,则Qtcreator毫无问题(它使用6.6 而不是 6.7 编译),但是使用Qt 6.7 的app还是有问题。
msys环境:
user@worker UCRT64 ~
$ qmake6 --version
QMake version 3.1
Using Qt version 6.7.0 in C:/msys64/ucrt64/lib
Qt Creator 13.0.0
故障 windows环境:
$screenfetch
.., guest@localhost
....,,:;+ccllll OS: Microsoft Windows 11 Home Edition (v10.0.22631) 64-bit
...,,+:; cllllllllllllllllll Kernel: x86_64 MINGW64_NT-10.0-22631 3.4.10.x86_64
,cclllllllllll lllllllllllllllllll Uptime: 503m
llllllllllllll lllllllllllllllllll Packages: 1307
llllllllllllll lllllllllllllllllll Shell: bash 5.2.26
llllllllllllll lllllllllllllllllll Resolution: 1920x1080
llllllllllllll lllllllllllllllllll DE: Modern UI/Metro
llllllllllllll lllllllllllllllllll WM: DWM/Explorer
WM Theme:Themesaero
llllllllllllll lllllllllllllllllll CPU: Intel Core i7-10510U @ 8x 2.31GHz
llllllllllllll lllllllllllllllllll GPU: Intel(R) UHD Graphics
llllllllllllll lllllllllllllllllll RAM: 4172MiB / 24306MiB
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
`'ccllllllllll lllllllllllllllllll
`'""*:: :ccllllllllllllllll
````''"*::cll
``
错误图片:
上图的spinBox里的文字全部显示不全。
上图帮助系统中,ComboBox弹出的选项列表背景前景几乎一样,看不清
原因分析:
这个问题是错误的StyleSheet导致的。应该是Qt 6.7 的 windows 11风格没有在各种 DPI下进行严格的测试。鉴于官方的 Official Online Installer 对应的 Qt6.6的 qtcreator 没有问题,只能是 msys2 版本太高,提前暴露了Qt6.7某些配置至少在 mingw下有问题。
解决方案:
最简单的方法是用fusion主题或者其他主题启动 QtCreator:
$ qtcreator --style fusion
此问题应该很快会解决。