qt中使用qss修改qpushbutton的边框
您可以使用QSS(Qt Style Sheets)来修改QPushButton的边框样式。以下是一个示例代码,展示如何使用QSS修改QPushButton的边框:
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// 创建一个QPushButton
QPushButton button("Button");
button.show();
// 使用QSS修改QPushButton的边框样式
button.setStyleSheet("QPushButton {"
"border-style: solid;" // 设置边框样式为实线
"border-width: 2px;" // 设置边框宽度为2像素
"border-color: red;" // 设置边框颜色为红色
"}");
return app.exec();
}
在上面的示例中,我们使用setStyleSheet()函数为QPushButton设置了一个QSS样式表。在QSS样式表中,我们通过设置border-style、border-width和border-color来修改QPushButton的边框样式
原文地址: https://www.cveoy.top/t/topic/iJRy 著作权归作者所有。请勿转载和采集!