VeighNa量化社区
你的开源社区量化交易平台 | vn.py | vnpy
Member
avatar
加入于:
帖子: 2
声望: 0

我想继承MainWindow然后做一些修改,但是简单继承之后,在界面上点击“连接TtsGateway”就会报错“TypeError: PySide6.QtCore.QObject.connect(): not enough arguments”, 我研究了很久,也问过GPT和Cursor,但是依然不清楚为什么会报错,请各位大佬指点一下~

环境信息和代码如下:

环境:

requires-python = ">=3.10"
dependencies = [
    "pyside6==6.3.0",
    "setuptools>=75.7.0",
    "tzlocal==5.2",
    "PySide6==6.3.0",
    "pyqtgraph==0.13.4",
    "qdarkstyle==3.2.3",
    "numpy==1.26.4",
    "pandas==2.2.1",
    "matplotlib==3.8.3",
    "seaborn==0.13.2",
    "ta-lib==0.4.24",
    "deap==1.4.1",
    "pyzmq==25.1.2",
    "plotly==5.20.0",
    "importlib-metadata==7.0.2",
    "tqdm==4.66.2",        
    "vnpy==3.9.4",
    "vnpy-spreadtrading>=1.2.5",
    "vnpy-tts>=6.7.2.0",    
    "dynaconf>=3.2.6",
    "loguru>=0.7.3",    
]

代码

from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import create_qapp
from vnpy_tts import TtsGateway

from vnpy.trader.ui import MainWindow
from vnpy_spreadtrading import SpreadTradingApp


from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow


class NewMainWindow(MainWindow):
    def __init__(self, main_engine, event_engine):
        super().__init__(main_engine=main_engine, event_engine=event_engine)


def main():
    """"""
    qapp = create_qapp()

    event_engine = EventEngine()

    main_engine = MainEngine(event_engine)
    main_engine.add_gateway(TtsGateway)
    main_engine.add_app(SpreadTradingApp)

    main_window = NewMainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()


if __name__ == "__main__":
    main()

报错截图

description

description

description

Member
avatar
加入于:
帖子: 1787
声望: 135

MainWindow有些特殊,其中的connect函数和QObject的函数重名了。

你的NewMainWindow重载下connect函数,直接把MainWindow那边的复制过来即可

Member
avatar
加入于:
帖子: 2
声望: 0

MTF wrote:

MainWindow有些特殊,其中的connect函数和QObject的函数重名了。

你的NewMainWindow重载下connect函数,直接把MainWindow那边的复制过来即可

感谢大佬!!我研究了半天都没想到是这个问题,试了cursor给的各种解决方案也不行,大佬一句话就解决了

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】