如何解决Qt Designer 5.11.1 未将字体粗细设置为正确的类型
运行 cmake 时出现以下错误:
C:/Users/Owner/OneDrive/Documents/BJT/src/ui_BJT.h:126:24: error: invalid conversion from 'int' to 'QFont::Weight' [-fpermissive]
font.setWeight(75);
^~
In file included from C:/Qt/6.1.2/mingw81_64/include/QtWidgets/qwidget.h:49,from C:/Qt/6.1.2/mingw81_64/include/QtWidgets/qabstractbutton.h:48,from C:/Qt/6.1.2/mingw81_64/include/QtWidgets/qcheckbox.h:44,from C:/Qt/6.1.2/mingw81_64/include/QtWidgets/QCheckBox:1,from C:/Users/Owner/OneDrive/Documents/BJT/src/ui_BJT.h:14,from C:\Users\Owner\OneDrive\Documents\BJT\src\ui_BJT.cpp:1:
C:/Qt/6.1.2/mingw81_64/include/QtGui/qfont.h:200:27: note: initializing argument 1 of 'void QFont::setWeight(QFont::Weight)'
void setWeight(Weight weight);
~~~~~~~^~~~~~
违规代码在这里:
QFont font;
font.setFamily(QStringLiteral("Times New Roman"));
font.setPointSize(16);
font.setBold(true);
font.setWeight(75);
titleLabel->setFont(font);
解决方法是更改 font.setWeight(75);到 font.setWeight(QFont::Weight(75));我可以轻松做到。但是,这是生成的代码,不应更改。这是 Qt Designer 的错误吗?我可以在 Qt Designer 中做些什么来解决这个问题(也许使用样式表)?这个问题会在 Qt Designer 的更高版本中修复吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。