This short program
import sys
from PySide6.QtCore import Qt
from PySide6.QtWidgets import (
QApplication,
QGraphicsScene,
QGraphicsView,
QGraphicsWidget,
)
app = QApplication(sys.argv)
scene = QGraphicsScene()
view = QGraphicsView(scene)
view.resize(400, 300)
window = QGraphicsWidget(None, Qt.Window)
window.resize(200, 200)
scene.addItem(window)
view.setScene(scene)
view.show()
sys.exit(app.exec())
Produces the following output in windows:
Functionaly it is exactly what I want, since I can natively drag the window inside the GraphicsView. But I haven't found a way to change the style of the graphical elements that make up the window: titlebar, close button, frame.
QGraphicsWidget instances don't have a setStyleSheet method, and those elements are unaffected by the palette I setup to try to resemble a motif look:
palette.setColor(QPalette.ColorRole.Window, QColor(212, 208, 200))
palette.setColor(QPalette.ColorRole.WindowText, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.Base, QColor(212, 208, 200))
palette.setColor(QPalette.ColorRole.AlternateBase, QColor(212, 208, 200))
palette.setColor(QPalette.ColorRole.ToolTipBase, QColor(212, 208, 200))
palette.setColor(QPalette.ColorRole.ToolTipText, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.Text, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.Button, QColor(212, 208, 200))
palette.setColor(QPalette.ColorRole.ButtonText, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.BrightText, QColor(255, 255, 255))
palette.setColor(QPalette.ColorRole.Link, QColor(0, 0, 255))
palette.setColor(QPalette.ColorRole.Highlight, QColor(0, 0, 255))
palette.setColor(QPalette.ColorRole.HighlightedText, QColor(255, 255, 255))
palette.setColor(QPalette.ColorRole.Light, QColor(255, 255, 255))
palette.setColor(QPalette.ColorRole.Midlight, QColor(212, 208, 200))
palette.setColor(QPalette.ColorRole.Dark, QColor(128, 128, 128))
palette.setColor(QPalette.ColorRole.Mid, QColor(160, 160, 160))
palette.setColor(QPalette.ColorRole.Shadow, QColor(96, 96, 96))
palette.setColor(QPalette.ColorRole.LinkVisited, QColor(0, 0, 255))
palette.setColor(QPalette.ColorRole.WindowText, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.ButtonText, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.Text, QColor(0, 0, 0))
palette.setColor(QPalette.ColorRole.BrightText, QColor(255, 255, 255))
palette.setColor(QPalette.ColorRole.HighlightedText, QColor(255, 255, 255))
palette.setColor(QPalette.ColorRole.Link, QColor(0, 0, 255))
palette.setColor(QPalette.ColorRole.LinkVisited, QColor(0, 0, 255))
So what is the easiest way to style those elements, hopefully avoiding having to rewrite the code for painting the window frame, window movement and closing behaviour?