Connecting to OCX COM object : QAxBase::qt_metacall: Object is not initialized, or initialization failed
-
Hi, I have the same problem described in this page but the answer given there doesn't solve my problem because I alredy use QApplication.
"ocx1lib.h" is given using dumpcpp.exe as the page above.
My code is :
#include "mainwindow.h" #include "ocx1lib.h" #include <QApplication> #include <QDebug> #include "combaseapi.h" using namespace OCX1Lib; int main(int argc, char *argv[]) { _DDctl * readObj = new _DDctl(); //qDebug() << readObj->setControl("{22842328-3FCE-11D1-9B93-0020AF524FA5}"); readObj->SetLinkTopic("ncdde|ncu840d"); //QApplication a(argc, argv); //MainWindow w; //w.show(); //return a.exec(); return 0; }```
-
Sorry for the delay I can only post once every 600 second(s), I forget to add the link
https://forum.qt.io/topic/69584/connecting-to-com-object-requested-control-could-not-be-instantiated
and the error I'm having is this while executing the code above :
QAxBase::qt_metacall: Object is not initialized, or initialization failed -
@SAJMED said in Connecting to OCX COM object : QAxBase::qt_metacall: Object is not initialized, or initialization failed:
and the error I'm having is this while executing the code above :
QAxBase::qt_metacall: Object is not initialized, or initialization failedInitializing
QApplication
must be done before using anyQObject
based classe.
I think your code should be:int main(int argc, char *argv[]) { QApplication a(argc, argv); _DDctl * readObj = new _DDctl(); readObj->SetLinkTopic("ncdde|ncu840d"); //qDebug() << readObj->setControl("{22842328-3FCE-11D1-9B93-0020AF524FA5}"); //MainWindow w; //w.show(); //return a.exec(); return 0; }
-
Thank you @KroMignon for you help, It doesn't solve the problem.
-
@SAJMED said in Connecting to OCX COM object : QAxBase::qt_metacall: Object is not initialized, or initialization failed:
It doesn't solve the problem.
Perhaps calling
setControl()
has to be done, why to do you comment it out?int main(int argc, char *argv[]) { QApplication a(argc, argv); _DDctl * readObj = new _DDctl(); qDebug() << readObj->setControl("{22842328-3FCE-11D1-9B93-0020AF524FA5}"); readObj->SetLinkTopic("ncdde|ncu840d"); //MainWindow w; //w.show(); //return a.exec(); return 0; }
I have never use
ActiveQt
, maybe there is another forum user which may help you. -
when I call setControl()
I have this error :CoCreateInstance failure (Classe non enregistrée)
QAxBase::setControl: requested control {22842328-3FCE-11D1-9B93-0020AF524FA5} could not be instantiated
QAxBase::qt_metacall: Object is not initialized, or initialization failed