Я использовал pyQt4. Я хотел бы преобразовать pyQt5. , но я не мог использовать old-style signal and slot в pyQt5, потому что pyQt5 поддерживает только new-style signal and slot. Поэтому я не мог получать события из ActiveX.Как получить события ActiveX в pyQt5?
Пожалуйста, дайте мне решение.
этот код pyQt4 версия.
from PyQt4.QtCore import SIGNAL, QObject
from PyQt4.QAxContainer import QAxWidget
class ActiveXExtend(QObject):
def __init__(self, view):
super().__init__()
self.view = view
self.ocx = QAxWidget("KHOPENAPI.KHOpenAPICtrl.1")
# receive ActiveX event.
self.ocx.connect(self.ocx, SIGNAL("OnReceiveMsg(QString, QString, QString, QString)"), self._OnReceiveMsg)
# event handler
def _OnReceiveMsg(self, scrNo, rQName, trCode, msg):
print("receive event")
Я пытаюсь преобразовать pyQt5.
from PyQt5.QtCore import QObject
from PyQt5.QAxContainer import QAxWidget
class ActiveXExtend(QObject):
def __init__(self, view):
super().__init__()
self.view = view
self.ocx = QAxWidget("KHOPENAPI.KHOpenAPICtrl.1")
# receive ActiveX event.
# old-style is not supported.
# self.ocx.connect(self.ocx, SIGNAL("OnReceiveMsg(QString, QString, QString, QString)"), self._OnReceiveMsg)
# event handler
def _OnReceiveMsg(self, scrNo, rQName, trCode, msg):
print("receive event")
Просто угадать немного, но вы были бы в состоянии [соединить слоты по имени] (http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#connecting-slots-by-name) ? – ekhumoro