首页 > 解决方案 > PyQt5 QMainWindow/QAxWidget线程问题

问题描述

我想在QMainWindow和之间有不同的线程QAxWidget。据我所知,QMainWindow应该有MainThread。所以我写下代码如下。

from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Main_Thread(QtWidgets.QMainWindow):
    def __init__(self):
        # setting QMainWindow with widgets... + super().__init__()
        sub_instance = Sub_Thread()
        sub_thread = QtCore.QThread()
        sub_instance.moveToThread(sub_thread)
        sub_thread.started.connect(sub_instance.run)
        sub_thread.start()
class Sub_Thread(QObject):
    def __init__(self):
        super().__init__()
    def run(self):
        ocx = QAxContainer.QAxWidget('connection path')
        ocx.signal.connect(slot) # line★

ocx(AcitveX)有很多信号...

ocx当我写'line★'时出现没有那种信号的错误

发生了什么样的问题? ocx应该在MainThread中进行吗?

标签: pythonmultithreadingpyqt5qaxwidget

解决方案


推荐阅读