Problem
I’d like to jump the gun on invent.kde.org/teams/vdg/issues/-/issues/12. However, although I’ve got the frame override 90% of the way there, that last 10% defeats me.
As an example, I created a sample application that has the undermentioned appearance under org.kde.breezedark.desktop
by default:
Specifically, I wanted QToolButton
s, so I managed to wrangle the undermentioned by going way beyond my area of knowledge (though, I can do CSS):
#!/usr/bin/env python3.13
from PyQt6.QtWidgets import \
QApplication, \
QMainWindow, \
QToolBar, \
QToolButton
from PyQt6.QtGui import \
QIcon, \
QPalette
class MainWindow(QMainWindow):
"""
Subclasses `QMainWindow`.
"""
def __init__(self):
super().__init__()
self.toolbar = QToolBar("Main Toolbar")
button = QToolButton()
button.setText("Click Me")
# Example KDE icon:
button.setIcon(QIcon.fromTheme("document-new"))
# Get the *active* system palette to adapt to light/dark mode:
palette = QApplication.palette()
border_color = palette.color(QPalette.ColorRole.Mid).name()
hover_color = palette.color(QPalette.ColorRole.Dark).name()
pressed_color = palette.color(QPalette.ColorRole.Light).name()
bg_color = palette.color(QPalette.ColorRole.Button).name()
# Apply stylesheet with dynamically retrieved colors:
button.setStyleSheet(f"""
QToolButton {{
border: 1px solid {border_color};
border-radius: 4px;
padding: 4px;
}}
QToolButton:hover {{
border: 1px solid {hover_color};
}}
QToolButton:pressed {{
border: 1px solid {pressed_color};
background-color: {bg_color};
}}
""")
self.toolbar.addWidget(button)
self.addToolBar(self.toolbar)
app = QApplication([])
window = MainWindow()
window.show()
app.exec()
However, it only works in Breeze Light:
Does anyone know what I’m doing incorrectly?
Meta
I’d ask this at Qt’s NodeBB forum, but this is about Breeze, so I’ve at least initially asked this here.