我的 Qt 版本是 4.7.1,我想将 QLineEdit 的背景颜色设置为与窗口颜色相同,我使用这种方式:
QString bgColorName = palette().color(QPalette::Normal, QPalette::Window).name();
QString strStyleSheet = QString("QLineEdit {background-color: ").append(bgColorName).append("}");
ui->lineEdit->setStyleSheet(strStyleSheet);
我尝试获取背景颜色名称,然后设置QLineEdit的样式表,但是,运行应用程序后,我发现QLineEdit的颜色有点不同,也就是说,如果你仔细看,你可以看到不同,在 Win7 和 Mac 上。谁能帮我找到一种方法来获得正确的对话框背景颜色,提前谢谢你。