要设置 QPushButton 在悬浮时的字体颜色为白色,可以在 QPushButton:hover
的样式表中添加 color
属性。你可以修改你的样式表如下:
QString styleSheetbutton = QString("QPushButton {"
"border: 1px solid rgb(102, 138, 222);"
"border-radius: 3px;"
"background-color: rgb(221, 222, 226 );"
"background-repeat: no-repeat;"
"background-position: right;"
"background-origin: content;"
"padding-right: 15px;"
"text-align: center;"
"} "
""
"QPushButton:hover {"
"background-color: rgb(51, 121, 204 );"
"color: white;" // 设置悬浮状态下的字体颜色为白色
"}");
在这段代码中,"color: white;"
被添加到 QPushButton:hover
部分,以确保当按钮悬停时,其文字颜色会变成白色。
内容由零声教学AI助手提供,问题来源于学员提问