可能产生这种情况的原因有两种可能性:一是没有正确设置QDialog的样式表,二是可能有其他样式表或代码覆盖了圆角的设置。

首先,确保正确设置了QDialog的样式表。可以通过以下方式来设置样式表:

CallReminderDialog::CallReminderDialog(QWidget *parent) : QDialog(parent)
{
    setStyleSheet("QDialog#CallReminderDialog{background-color: rgba(20, 25, 29,1); border-radius:20px;}");
}

如果仍然没有生效,可以尝试在样式表中添加!important来强制应用样式:

CallReminderDialog::CallReminderDialog(QWidget *parent) : QDialog(parent)
{
    setStyleSheet("QDialog#CallReminderDialog{background-color: rgba(20, 25, 29,1) !important; border-radius:20px !important;}");
}

如果以上方法仍然无效,可能是其他样式表或代码覆盖了圆角的设置。可以尝试在设置圆角样式之前,先将其他可能影响圆角的样式表或代码移除或禁用,然后再重新设置圆角样式。

另外,还需要确保在QWidget的派生类中正确设置了QDialog的objectName属性为"CallReminderDialog",例如:

CallReminderDialog::CallReminderDialog(QWidget *parent) : QDialog(parent)
{
    setObjectName("CallReminderDialog");
}

通过以上方法,应该能够正确设置QDialog的背景色和圆角样式。如果仍然无效,可能需要检查其他可能的代码或样式表是否对QDialog的样式有影响

QDialog#CallReminderDialog background-color rgba20 25 291; border-radius20px !important;背景色生效圆角没有生效

原文地址: https://www.cveoy.top/t/topic/isvx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录