zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.61k stars 541 forks source link

[Bug]: Closes everytime I start it #759

Closed MunaAlaneme closed 8 months ago

MunaAlaneme commented 8 months ago

What happened?

I installed other versions of it and it glitched.

Operation System

Windows 11 23H2

Python Version

Python 3.11.4 64-bit

PyQt/PySide Version

PyQt 5.15.10

PyQt/PySide-Fluent-Widgets Version

v1.5.0

How to Reproduce?

Install other versions Run it

Minimum code

# coding:utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication, QWidget, QSlider

from qfluentwidgets import HollowHandleStyle, Slider, setTheme, Theme

class Demo1(QWidget):

    def __init__(self):
        super().__init__()
        self.resize(300, 150)
        self.setStyleSheet("Demo1{background: rgb(184, 106, 106)}")

        # customize style
        style = {
            "sub-page.color": QColor(70, 23, 180)
        }
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setStyle(HollowHandleStyle(style))

        # need adjust height
        self.slider.resize(200, 28)
        self.slider.move(50, 61)

class Demo2(QWidget):

    def __init__(self):
        super().__init__()
        # setTheme(Theme.DARK)
        # self.setStyleSheet('Demo2{background: rgb(32,32,32)}')
        self.setStyleSheet('Demo2{background: white}')

        self.resize(300, 300)

        self.slider1 = Slider(Qt.Horizontal, self)
        self.slider1.setFixedWidth(200)
        self.slider1.move(50, 30)

        self.slider2 = Slider(Qt.Vertical, self)
        self.slider2.setFixedHeight(150)
        self.slider2.move(140, 80)

if __name__ == '__main__':
    # enable dpi scale
    QApplication.setHighDpiScaleFactorRoundingPolicy(
        Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

    app = QApplication(sys.argv)
    w1 = Demo1()
    w1.show()
    w2 = Demo2()
    w2.show()
    sys.exit(app.exec_())

Error:
    Traceback (most recent call last):
  File "d:\Muna's Useless Python Stuff\GameLauncher\assets\games\FlappyBird\FlappyBird copy.py", line 57, in <module>
    w1 = Demo1()
         ^^^^^^^
  File "d:\Muna's Useless Python Stuff\GameLauncher\assets\games\FlappyBird\FlappyBird copy.py", line 22, in __init__
    self.slider.setStyle(HollowHandleStyle(style))
TypeError: setStyle(self, a0: QStyle): argument 1 has unexpected type 'HollowHandleStyle'
immiProgrammer commented 8 months ago

maybe u can modified the qfluentwidgets code or import other class with same name HollowHandleStyle

immiProgrammer commented 8 months ago

first u print HollowHandleStyle.__bases__ if your output didn't looks like (<class 'PyQt5.QtWidgets.QProxyStyle'>,) then its your problem

zhiyiYo commented 8 months ago

Try 5.15.7