Qt Designer 的预览 ui 和 运行 在 python 中不一样
Qt Designer's preview ui is not the same when it running in python
这是预览
这是 运行 在 python
时的样子
Qt根据环境变量等各种标志来处理启用的各种样式,Qt Designer可能默认使用了一些样式,所以预览显示的样式可能与应用程序不同运行.
分析样式我觉得Qt Designer使用的是"fusion"样式,所以解决方法是添加:
app.setStyle("fusion")
如果您想使用 Qt Designer 中的其他样式可视化您的设计,您必须执行:Form-> Preview in -> style
如果您想了解安装中可用的所有样式,您可以运行以下内容:
from PySide2 import QtWidgets
print(QtWidgets.QStyleFactory.keys())
在我的例子中,我得到以下信息:
['Breeze', 'bb10dark', 'bb10bright', 'cleanlooks', 'gtk2', 'cde', 'motif', 'plastique', 'Oxygen', 'Windows', 'Fusion']
这是预览
这是 运行 在 python
时的样子Qt根据环境变量等各种标志来处理启用的各种样式,Qt Designer可能默认使用了一些样式,所以预览显示的样式可能与应用程序不同运行.
分析样式我觉得Qt Designer使用的是"fusion"样式,所以解决方法是添加:
app.setStyle("fusion")
如果您想使用 Qt Designer 中的其他样式可视化您的设计,您必须执行:Form-> Preview in -> style
如果您想了解安装中可用的所有样式,您可以运行以下内容:
from PySide2 import QtWidgets
print(QtWidgets.QStyleFactory.keys())
在我的例子中,我得到以下信息:
['Breeze', 'bb10dark', 'bb10bright', 'cleanlooks', 'gtk2', 'cde', 'motif', 'plastique', 'Oxygen', 'Windows', 'Fusion']