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.37k stars 254 forks source link

AttributeError: 'PySide6.QtWidgets.QPushButton' object has no attribute 'setStyleSheet' #79

Open UDBIAWDIF opened 1 year ago

UDBIAWDIF commented 1 year ago

When running the 'examples\full_features: python main.py --pyside6' given, I encountered the problem of AttributeError: 'PySide6.QtWidgets.QPushButton' object has no attribute 'setStyleSheet':

qt.pysideplugin: Environment variable PYSIDE_DESIGNER_PLUGINS is not set, bailing out. qt.pysideplugin: No instance of QPyDesignerCustomWidgetCollection was found. qt.webenginecontext:

GL Type: disabled Surface Type: OpenGL Surface Profile: CompatibilityProfile Surface Version: 4.5 QSG RHI Backend: D3D11 Using Supported QSG Backend: no Using Software Dynamic GL: no Using Multithreaded OpenGL: yes

Init Parameters:

qt.pysideplugin: No instance of QPyDesignerCustomWidgetCollection was found. Traceback (most recent call last): File "D:\project\python\qt-material\examples\full_features\main.py", line 207, in frame = RuntimeStylesheets() ^^^^^^^^^^^^^^^^^^^^ File "D:\project\python\qt-material\examples\full_features\main.py", line 111, in init self.show_dock_theme(self.main) File "D:\GreenSoft\Python3.11\Lib\site-packages\qt_material-2.13-py3.11.egg\qt_material__init__.py", line 750, in show_dock_theme self.update_buttons() File "D:\GreenSoft\Python3.11\Lib\site-packages\qt_material-2.13-py3.11.egg\qt_material__init__.py", line 627, in update_buttons button.setStyleSheet( ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'PySide6.QtWidgets.QPushButton' object has no attribute 'setStyleSheet'. Did you mean: 'style_sheet'?

cabooster commented 1 year ago

'setStyleSheet' change to: try: button.setStyleSheet( f""" {{ background-color: {color}; color: {text_color}; border: none; }}""" ) except: button.style_sheet = f""" {{ background-color: {color}; color: {text_color}; border: none; }}"""