首页| 论坛| 消息

标题:使用activex控件时如何传递事件
作者:wenjin1314
日期:2013-09-05 11:19
内容:

需要使用activex控件,我使用方法大概如下:
QAxWidget *m_lvcam;//定义
//连接初始化
m_lvcam = new QAxWidget(m_parent,0);
m_lvcam->resize(200,200);
m_lvcam->setControl(QString::fromUtf8("{061A62BE-04A3-4EA2-84F9-2E3479887959}"));
m_lvcam->showNormal();
//调用
m_lvcam->dynamicCall("Connect(qint16,qint16,qint16,qint16,const LPCTSTR)",
m_nCamera,m_nPort,m_nDevice,m_nInterface,m_sServerIP);
以上都没有什么问题,现在问题是控件里有几个事件需要连接,不知道如何连接。
但是我知道在VC与delphi里是如何使用的,如下:
C++里面是如下定义的:
BEGIN_EVENTSINK_MAP(CFSWinView, CFormView)
//{{AFX_EVENTSINK_MAP(CFSWinView)
ON_EVENT(CFSWinView, IDC_LVCAMCTRL1, 103 /* CameraEvent */, OnCameraEvent, VTS_I4)
ON_EVENT(CFSWinView, IDC_LVCAMCTRL1, 104 /* ResourceChanged */, OnResourceChanged, VTS_BSTR VTS_VARIANT)
//}}AFX_EVENTSINK_MAP
ON_EVENT(CFSWinView, IDC_LVCAMCTRL1, 102, CFSWinView::CamCmdReplyLvcamctrl1, VTS_BSTR)
END_EVENTSINK_MAP()
这样就把OnCameraEvent,OnResourceChanged,CamCmdReplyLvcamctrl1 三个事件连接起来了。
在Delphi里面使用方法如下:
FLVCam: TLVCam;
FLVCam.OnCamCmdReply := OnLVCamCamCmdReply;
FLVCam.OnCameraEvent := OnLVCamCameraEvent;
FLVCam.OnResourceChanged := OnLVCamResourceChanged;
但是QT里面是怎么个使用方法,望大侠们不吝赐教。。。


#1 [wenjin1314 09-05 13:40]
问题已经解决了,还是用信号与槽关联,activeX里的事件把它当成信号,Qt里面定义相应槽进行关联就可以。
connect(m_lvcam,SIGNAL(CameraEvent(int)),this,SLOT(OnLVCamCameraEvent(int)));
connect(m_lvcam,SIGNAL(CamCmdReply(const LPCTSTR)),this,SLOT(OnLVCamCamCmdReply(LPCTSTR)));
connect(m_lvcam,SIGNAL(ResourceChanged(const LPCTSTR,QVariant)), this,SLOT(OnLVCamResourceChanged(const LPCTSTR,QVariant)));
#2 [wenjin1314 09-05 13:41]
这是在C++ GUI Qt 4 编程上找到答案的,里面有一节内容为
#3 [liulin188 09-06 09:01]
good
#4 [初一 09-25 17:47]
http://pan.baidu.com/s/1efEQ7
http://t.163.com/event/info/eventId/-1937819518098304671
http://t.163.com/event/info/eventId/-981273144661307270
http://t.163.com/event/info/eventId/7947289849108671
http://t.163.com/event/info/eventId/9148364491793342506
http://t.163.com/event/info/eventId/-3720204668644585607
http://t.163.com/event/info/eventId/9146905595727730778
http://t.163.com/event/info/eventId/-3377727777187160841
http://t.163.com/event/info/eventId/3600721153446111371
http://t.163.com/event/info/eventId/1623357964657994343
http://t.163.com/event/info/eventId/3095141195573980478
http://t.163.com/event/info/eventId/-8561829950038191215
http://t.163.com/event/info/eventId/-2178496729063136713
http://t.163.com/event/info/eventId/-7772974592190348506
http://t.163.com/event/info/eventId/8667327288343520965
http://t.163.com/event/info/eventId/1034137465817843303
http://t.163.com/event/info/eventId/-6819333266584126833
http://t.163.com/event/info/eventId/-2077796618415045209
http://t.163.com/event/info/eventId/-3129405404983603936
http://t.163.com/event/info/eventId/-1617054959294763309
#5 [小罗 07-01 13:48]
您好,我最近在开发指纹仪的ActiveX控件,也不知道如何传递事件,能否指教一下?

回复 发表
主题 版块