analitics

Pages

Saturday, January 10, 2026

Python Qt6 : use default PyQt styles to PyQt6 applications.

Today, about PyQt Styles to PyQt6 Applications.
This works with default themes and how to change these, and using different types of custom styling.
First , let's see the source code with default themes:
from PyQt6.QtWidgets import QStyleFactory
print(QStyleFactory.keys())
['windows11', 'windowsvista', 'Windows', 'Fusion']
Let's see the source code for this simple script with this theme windows11:
import sys
from PyQt6.QtWidgets import (
    QApplication, QLabel, QLineEdit, QComboBox, QPushButton,
    QCheckBox, QSlider, QVBoxLayout, QWidget
)
from PyQt6.QtCore import Qt

app = QApplication(sys.argv)
app.setStyle('windows11')

window = QWidget()
layout = QVBoxLayout(window)

# 1. QLabel
layout.addWidget(QLabel("Acesta este un QLabel"))

# 2. QLineEdit
layout.addWidget(QLineEdit("Text editabil"))

# 3. QComboBox
combo = QComboBox()
combo.addItems(["Optiunea 1", "Optiunea 2", "Optiunea 3"])
layout.addWidget(combo)

# 4. QCheckBox
layout.addWidget(QCheckBox("Bifează această opțiune"))

# 5. QSlider
slider = QSlider(Qt.Orientation.Horizontal)
layout.addWidget(slider)

# 5. QPushButton
button = QPushButton('Simple button !')
layout.addWidget(button)

# show the main windows 
window.show()
sys.exit(app.exec())