Closed abyss-zues closed 7 months ago
抱歉,无法复现这个问题,能不能贴一下你的出问题的代码
import sys
from PySide6.QtWidgets import QApplication
from qfluentwidgets import CardWidget
class A:
pass
class DemoUi(CardWidget, A):
def __init__(self):
super().__init__()
if __name__ == "__main__":
app = QApplication(sys.argv)
a = DemoUi()
a.show()
sys.exit(app.exec())
A類一般就是使用QtDesigner生成的文件中的類
问题复现了,应该是因为Qt内置类型的init没有take keyword arguments导致的,kwargs一路传递到了object,所以报错了,改成position arguments就没问题了 该问题只发生在PySide6上,可能会发生在PyQt6上,暂时没有做测试 怀疑是Shiboken6的问题,暂时不做修复,我去读一下qt源码看看 贴一下我的最小测试代码方便测试
import inspect
import PySide6
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
class A(object):
def setupUi(self, Form):
if not Form.objectName():
Form.setObjectName(u"Form")
Form.resize(400, 300)
self.retranslateUi(Form)
QMetaObject.connectSlotsByName(Form)
# setupUi
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
# retranslateUi
class Fun:
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
class Card(Fun, QWidget):
def __init__(self, parent=None) -> None:
# Not work!!!
super().__init__(parent=parent)
# work perfectly
# super().__init__(parent)
class Demo(Card, A):
def __init__(self) -> None:
super().__init__()
app = QApplication([])
d = Demo()
好像 PySide 6.6.2 之后就会有这种问题,你用 6.4.2 试试
估计是shiboken的问题
估计是shiboken的问题
等 Qt 修吧 💩
修改了 BackgroundAnimationWidget
的构造函数
@zhiyiYo
修改了
BackgroundAnimationWidget
的构造函数
这样修好像不行,PySide6.5添加了一个补丁会跳过多继承中positional arguments。 见https://codereview.qt-project.org/c/pyside/pyside-setup/+/471544 我在Qt的追踪器提了这个问题,回复说QObject必须在继承顺序中处于第一位,我再研究研究
@zhiyiYo
修改了
BackgroundAnimationWidget
的构造函数这样修好像不行,PySide6.5添加了一个补丁会跳过多继承中positional arguments。
见https://codereview.qt-project.org/c/pyside/pyside-setup/+/471544
我在Qt的追踪器提了这个问题,回复说QObject必须在继承顺序中处于第一位,我再研究研究
出问题都是多继承导致的🤣,我就觉得是多继承的问题
我测试了他给的复现代码,不会报错了
我测试了他给的复现代码,不会报错了
这么改确实就没问题了,我写的最小复现当时就是这么改 OK 了,就是不知道这么改会不会影响别的什么地方。改了之后我跑了 Demo 和 Gallery 相关,都没问题。
后续见Implement multiple inheritance correctly, 2nd. amendment,预计下个版本修复,建议到时候改回去。
另外,可以不继承自Ui类改为使用ui类的对象来初始化ui,这个bug是因为ui类没有super().__init__()
导致的,貌似官方现在更推荐这么做。
PySide 6.7.0 修复了多重继承的问题,但是又加了新的 bug #839
What happened?
在使用CardWidget時,會報錯,保持内容如下: 經debug定位,發現是BackgroundAnimationWidget的如下地方報錯: 第83行有問題,把'*args, **kwargs'刪除后問題消失,可以正常使用。 但是不解的是把83行整體刪除卻也會報錯
Operation System
Windows 11 23H2
Python Version
3.11.8 64位
PyQt/PySide Version
PySide 6.6.2
PyQt/PySide-Fluent-Widgets Version
pyside6-fluent-widgets 1.5.4
How to Reproduce?
創建類繼承CardWidget,並運行
Minimum code