QDarkStyleSheet

3.2.3 · active · verified Thu Apr 16

QDarkStyleSheet (qdarkstyle) provides a comprehensive dark and light stylesheet for C++/Python Qt applications. It offers a consistent, modern theme for your GUI, compatible with both PyQt5 and PySide2. The current version is 3.2.3, and it receives regular minor updates with occasional major releases for significant structural changes and new features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a PyQt5 application and apply the QDarkStyleSheet. Ensure you have PyQt5 (or PySide2) installed alongside qdarkstyle. The example creates a simple window with a button to showcase the applied theme.

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget
from PyQt5.QtCore import Qt

import qdarkstyle

def main():
    app = QApplication(sys.argv)

    # Apply the dark stylesheet for PyQt5
    app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
    # For PySide2, use:
    # app.setStyleSheet(qdarkstyle.load_stylesheet_pyside2())

    # Create a simple main window
    main_window = QMainWindow()
    main_window.setWindowTitle("QDarkStyle Demo")
    main_window.setGeometry(100, 100, 400, 200)

    central_widget = QWidget()
    main_window.setCentralWidget(central_widget)
    layout = QVBoxLayout(central_widget)

    button = QPushButton("Styled Button", main_window)
    layout.addWidget(button, alignment=Qt.AlignCenter)

    main_window.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()

view raw JSON →