Qt ActiveX“;未知错误“;

Qt ActiveX“;未知错误“;,qt,com,activex,Qt,Com,Activex,我正在致力于将T-Cube电机控制器()集成到基于Qt-4.8.1包的软件中。由于没有手册或任何种类的教程,如何检索ActiveX对象以及如何调用方法,我做了以下工作 1) 在Windows注册表中查找类似于电机控制器名称的单词。找到具有CLSID“{3CE35BF3-1E13-4D2C-8C0B-DEF6314420B3}”的候选项 2) 尝试以以下方式初始化它(缩短提供的代码,删除所有结果检查以提高可读性): HRESULT h_result=coinitializex(NULL,COINI

我正在致力于将T-Cube电机控制器()集成到基于Qt-4.8.1包的软件中。由于没有手册或任何种类的教程,如何检索ActiveX对象以及如何调用方法,我做了以下工作

1) 在Windows注册表中查找类似于电机控制器名称的单词。找到具有CLSID“{3CE35BF3-1E13-4D2C-8C0B-DEF6314420B3}”的候选项

2) 尝试以以下方式初始化它(缩短提供的代码,删除所有结果检查以提高可读性):

HRESULT h_result=coinitializex(NULL,COINIT_多线程);
pd->moto=新的QAxObject();
初始化=moto->setControl({3CE35BF3-1E13-4D2C-8C0B-DEF6314420B3});
QString stri=browser->generateDocumentation();
对象->动态调用(“SetHWSerialNum(int)”,参数;
QVariantList参数;
params dynamicCall(“GetPosition(int,double&)”,params.toInt();
value=params[1]。toFloat();
QVariantList参数;

params您可以使用OLE查看器找到ActiveX对象。然后搜索类似于
所有对象下的
APT..
MG..
。然后找到参数
ProgID=MGMOTOR.MGMotorCtrl.1

现在在Qt中,不要使用
QAxObject
,而是使用
QAxWidget
。然后你会得到这样的结果:

QAxWidget* aptMotor;
QVariant chanID = QVariant(0);
aptMotor = new QAxWidget();
aptMotor->setControl("MGMOTOR.MGMotorCtrl.1");

//Nice html documentation on available functions
QFile file("out.html");
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << aptMotor->generateDocumentation();
file.close();

aptMotor->setProperty("HWSerialNum",QVariant(83853493));
aptMotor->dynamicCall("StartCtrl");

aptMotor->dynamicCall("EnableHWChannel(QVariant)",chanID);
QThread::sleep(1); // Give it time to enable the channel

double pos(0);
aptMotor->dynamicCall("SetAbsMovePos(QVariant,QVariant)",chanID,QVariant(pos));
aptMotor->dynamicCall("MoveAbsolute(QVariant,QVariant,QVariant)",chanID,0);

aptMotor->dynamicCall("StopCtrl");
QAxWidget*aptMotor;
QVariant chanID=QVariant(0);
aptMotor=新QAxWidget();
aptMotor->setControl(“MGMOTOR.MGMotorCtrl.1”);
//关于可用函数的漂亮html文档
QFile文件(“out.html”);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(文件(&F);
外生成文档();
file.close();
aptMotor->setProperty(“HWSerialNum”,QVariant(83853493));
aptMotor->dynamicCall(“StartCtrl”);
aptMotor->dynamicCall(“启用HWChannel(QVariant)”,通道ID;
QThread::sleep(1);//给它时间来启用通道
双pos(0);
aptMotor->dynamicCall(“SetAbsMovePos(QVariant,QVariant)”,chanID,QVariant(pos));
aptMotor->dynamicCall(“移动绝对(QVariant,QVariant,QVariant)”,chanID,0;
aptMotor->dynamicCall(“停止控制”);
QAxWidget* aptMotor;
QVariant chanID = QVariant(0);
aptMotor = new QAxWidget();
aptMotor->setControl("MGMOTOR.MGMotorCtrl.1");

//Nice html documentation on available functions
QFile file("out.html");
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << aptMotor->generateDocumentation();
file.close();

aptMotor->setProperty("HWSerialNum",QVariant(83853493));
aptMotor->dynamicCall("StartCtrl");

aptMotor->dynamicCall("EnableHWChannel(QVariant)",chanID);
QThread::sleep(1); // Give it time to enable the channel

double pos(0);
aptMotor->dynamicCall("SetAbsMovePos(QVariant,QVariant)",chanID,QVariant(pos));
aptMotor->dynamicCall("MoveAbsolute(QVariant,QVariant,QVariant)",chanID,0);

aptMotor->dynamicCall("StopCtrl");