Simple demo application I am trying to set the theme to dark. I would prefer a code version (non QtQuick preferred), but only way I see for Python is with a QtQuick config file, and even that does not work.
from PySide6 import QtWidgets
from PySide6 import QtQuick
if __name__ == '__main__':
app = QtWidgets.QApplication()
app.setApplicationDisplayName("Should be Dark Theme")
app.setStyle("Universal")
view = QtQuick.QQuickView()
view.show()
app.exec()
And I have a qtquickcontrols2.conf configuration file in the same directory. (Also tried setting QT_QUICK_CONTROLS_CONF to absolute path.)
[Controls]
Style=Material
[Universal]
Theme=Dark
[Material]
Theme=Dark
And yet, it's still bright white:
I do not care if it is Material or Universal style, just want some built in dark mode for the title bar. In the end, need a way to make the titlebar dark without creating a custom one.
Thank you for any guidance!
import sys
sys.argv += ['-platform', 'windows:darkmode=2']
app = QApplication(sys.argv)
above 3 lines can change your window to dark mode if you are using windows and Fusion style makes the app more beautiful, tested in windows 10, 11
example:-
from PySide6.QtWidgets import (
QApplication,
QCheckBox,
QComboBox,
QDateEdit,
QDateTimeEdit,
QDial,
QDoubleSpinBox,
QFontComboBox,
QLabel,
QLCDNumber,
QLineEdit,
QMainWindow,
QProgressBar,
QPushButton,
QRadioButton,
QSlider,
QSpinBox,
QTimeEdit,
QVBoxLayout,
QWidget,
)
import sys
sys.argv += ['-platform', 'windows:darkmode=2']
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Widgets App")
layout = QVBoxLayout()
widgets = [
QCheckBox,
QComboBox,
QDateEdit,
QDateTimeEdit,
QDial,
QDoubleSpinBox,
QFontComboBox,
QLCDNumber,
QLabel,
QLineEdit,
QProgressBar,
QPushButton,
QRadioButton,
QSlider,
QSpinBox,
QTimeEdit,
]
for w in widgets:
layout.addWidget(w())
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
app = QApplication(sys.argv)
app.setStyle('Fusion')
window = MainWindow()
window.show()
app.exec()