UN-GCPDS / qt-material

Material inspired stylesheet for PySide2, PySide6, PyQt5 and PyQt6
https://qt-material.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
2.3k stars 242 forks source link

Add pyside6 support #8

Closed lanzorg closed 3 years ago

lanzorg commented 3 years ago

https://www.qt.io/blog/qt-for-python-6-released

sharpordie commented 3 years ago

I tried this simple code:

import sys
from PySide6.QtWidgets import (QApplication, QGridLayout, QPushButton, QWidget, QProgressBar, QTableWidget)
from qt_material import apply_stylesheet

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Example")
        layout = QGridLayout()
        layout.addWidget(QTableWidget(), 0, 0, 1, 3)
        bar = QProgressBar()
        bar.setValue(50)
        bar.setTextVisible(False)
        layout.addWidget(bar, 1, 0, 1, 2)
        layout.addWidget(QPushButton("OK"), 1, 2, 1, 1)
        self.setLayout(layout)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    apply_stylesheet(app, theme='dark_teal.xml')
    window = Window()
    window.show()
    sys.exit(app.exec_())

But it have this error:

Traceback (most recent call last):
File ".\main.py", line 42, in <module>
apply_stylesheet(app, theme='dark_teal.xml')
File "C:\Users\Me\Desktop\pipenv_demo\.venv\lib\site-packages\qt_material\__init__.py", line 101, in apply_stylesheet
add_fonts()
File "C:\Users\Me\Desktop\pipenv_demo\.venv\lib\site-packages\qt_material\__init__.py", line 95, in add_fonts
QFontDatabase.addApplicationFont(os.path.join(fonts_path, font))
NameError: name 'QFontDatabase' is not defined
YeisonCardona commented 3 years ago

Hi @lanzorg and @sharpordie I just release a new version with PySide6 support https://github.com/UN-GCPDS/qt-material/commit/82739a4359e8b88974c66395fb6513950fe9fc11