QPushButton的边框不会更改为与背景色相同的颜色吗?

时间:2020-02-16 12:54:30

标签: python pyqt5

我正在制作一个我希望具有稍微弯曲的按钮的应用程序,但是我希望边框的颜色与按钮的背景相同。但是,似乎PyQt会自动将边框的一部分更改为与背景不同的颜色。这是一个可重复的示例:

import sys
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtWidgets import QMainWindow, QApplication

class Example(QMainWindow):
    def __init__(self):
        super(Example, self).__init__()
        self.setWindowTitle("Example")
        self.setFixedSize(350, 250)
        self.exampleUI()

        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        self.setFont(font)

        self.setStyleSheet("""
        QPushButton:hover:!pressed{
        border-color: #0077e6;
        background-color: #0077e6;
        }

        QPushButton:pressed{
        border-color: #0058ab;
        background-color: #0058ab;
        }

        QPushButton{
        border-style: outset;
        border-width: 2px;
        border-color: #0084ff;
        border-radius: 5px;
        background-color: #0084ff;
        }
        """)

    def exampleUI(self):
            self.exampleButton = QtWidgets.QPushButton(self)
            self.exampleButton.setGeometry(100, 100, 151, 41)
            self.exampleButton.setText("Click me")
            self.exampleButton.clicked.connect(self.btnFunction)

    def btnFunction(self):
        print("Clicked")

def window():
    app = QtWidgets.QApplication(sys.argv)
    win = Example()
    win.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    window()

0 个答案:

没有答案