Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How does the Fusion style create 2 adjacent border colors?



  • I am trying to replicate this effect in QSS (rather than using QPalette). How can I do this? Any CSS solution seems to use box-shadow or :before/:after which aren't supported by QSS.

    5baabf6d-b4a3-466d-854a-2f0d73f5e009-image.png

    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *
    from PyQt5.QtCore import *
    
    app = QApplication([])
    button = QPushButton("Button")
    layout = QVBoxLayout()
    layout.addWidget(button)
    container = QWidget()
    container.show()
    container.setLayout(layout)
    button.setFixedSize(QSize(100, 30))
    container.setFixedSize(QSize(500, 500))
    
    darkPalette = QPalette()
    darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
    darkPalette.setColor(QPalette.ButtonText, QColor(180, 180, 180))
    darkPalette.setColor(QPalette.Base, QColor(42, 42, 42))
    darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
    
    app.setStyle('Fusion')
    app.setPalette(darkPalette)
    app.exec_()
    

Log in to reply