PDA

View Full Version : QAxWidget - my controler could not be instantiated



ArnaudC
16th January 2013, 16:24
Hello,
I use Qt 4.8.4.

I try to use a ActiveX controler with this :



ui.setupUi(this);
QAxWidget * pWindow = new QAxWidget();
pWindow->setControl( "HKEY_CLASSES_ROOT\\TypeLib\\{ACFC5869-1D0F-4E2C-B898-05805607D542}" );

setCentralWidget( pWindow );


but I have

QAxBase::setControl: requested control HKEY_CLASSES_ROOT\TypeLib\{ACFC5869-1D0F-4E2C-B898-05805607D542} could not be instantiated
in the output command

I checked in the register base, the key seems to be right. Otherwise can I put the path to right .ocx directly in the setControl()?

d_stranz
16th January 2013, 22:00
What is the name of your control? Instantiate it by name instead of by GUID. For example, you can instantiate an Excel document using this:


pWindow->setControl( "Excel.Workspace" );

The other problem is that you are giving the GUID of the type library itself, not of the control contained inside it. If the control can't be instantiated by name, then you need to find the CLSID of the control, and send that to setControl(). That is going to be located under HKEY_CLASSES_ROOT\\CLSID, not TypeLib.

If you provide the control's CLSID, you probably do not need the full path. Simply put the CLSID in quotes as an argument:


pWindow->setControl( "{00020820-0000-0000-C000-000000000046}" );

You may not need the "{}" either. Using the name of the ocx file won't work - that's the same as using the typelib GUID. The type library just points to the container (OCX, DLL, EXE, whatever) that holds the code that knows how to instantiate controls. You can have any number of controls in a type library; you need to tell QAxWidget exactly which control you want, and the Windows Registry will tell it how to map the name to a CLSID and the CLSID to the type library where it lives.

ArnaudC
17th January 2013, 10:17
How can I know the name of my controler? (I mean the one that should be used by setControl()?)

Actually, I received AXCgmVSDK.ocx (it's a picture viewer). I used regsvr32 AXCgmVSDK.ocx to install it as they told me. They also gave me a sample program using this controler, it works, but it uses MSDN and I want Qt (because it's so much simplier). The thing is I don't know how to make it work.

So now, if I look into Regedit, I've got a trace of AXCgmVSDK in TypeLib, but I've got nothing in CLSID, is that normal? How should I use this controler?

Thank you.

d_stranz
17th January 2013, 19:33
If you have an MFC example, that must contain some information about the CLSID or name of the control. Even if they import the ocx into the project, it should still create some header files that contain the control information.

Microsoft provides the Ole/COM Object Viewer tool (oleview.exe) as part of the Windows Platform SDKs. This allows you to open a COM / ActiveX DLL or OCX file and see the objects inside it. It is no longer on the Visual Studio Tools menu, but you can probably find a copy if you search in your Microsoft SDKs folder in Program Files. If you don't find it, you may be able to download it from Microsoft or MSDN. Google is your friend.