如何在 QLineEdit 和 QPushButton 中只为边框的一侧设置样式表?

How to set Stylesheet for only one side of border in QLineEdit and QPushButton?

我尝试手动创建组合框。因此,行编辑应该与(下拉)按钮结合使用。因此我想隐藏行编辑的右边框和按钮的左边框。

我试过这个:

myLineEdit->setStyleSheet("QLineEdit{border-right: none;}");
myPushButton->setStyleSheet("QPushButton{border-left:none;}");

我也试过:

myLineEdit->setStyleSheet("QLineEdit{border: 1px 1px 0px 1px;}");

但是两者都不起作用。我哪里错了?

我觉得只有一个myLineEdit->setStyleSheet("QLineEdit{border-right: none;}");不行。我们需要设置边框样式、边框宽度和边框颜色。此代码对我有用:

myLineEdit->setStyleSheet( "QLineEdit{ border-width: 1px; border-style: solid; border-color: black white black black; }" );
myPushButton->setStyleSheet( "QAbstractButton{ border-width: 1px; border-style: solid; border-color: black black black white; }" );

你可以在这里看到边框样式的部分http://doc.qt.io/qt-5/stylesheet-reference.html

ui->txtValFloat->setStyleSheet( "QLineEdit{ border-width: 1px; border-style: solid; border-color:  red white black black;border-top-style:none; }" );

你会看到结果。
也可以看到 :border-bottom-color border-bottom-style border-bottom-width
我使用 qt 5.15