0

I want to have different thread between QMainWindow and QAxWidget. As I know, QMainWindow should have MainThread. So I write down code as below.

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) have a lot of signal...

I have error that ocx has no that kind of signal when I write 'line★'

What that kind of problem is occurring? ocx should be made in MainThread?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • osx is a QWidget so it should definitely be created in the main event thread. – Heike May 31 '21 at 13:23
  • 1
    please provide a [mre]. Why does QAxWidget need to live in another thread? – eyllanesc May 31 '21 at 16:18
  • OCX needs to install some files, so it's difficult to write down minimal reproductive example. Sorry about that. The reason why I need to put OCX in another thread is the OCX will make some signal in every seconds. So to use GUI(MainWindow) with no freezing, I think i gotta put OCX to other thread. I have no idea how to handle two item(MainWindow and OCX) in same thread... it's clear both of them will make kind of real time something – dongwookim Jun 01 '21 at 08:41

0 Answers0