Results 1 to 4 of 4

Thread: QAxWidget - my controler could not be instantiated

  1. #1
    Join Date
    Dec 2012
    Posts
    13
    Thanks
    1

    Default QAxWidget - my controler could not be instantiated

    Hello,
    I use Qt 4.8.4.

    I try to use a ActiveX controler with this :

    Qt Code:
    1. ui.setupUi(this);
    2. QAxWidget * pWindow = new QAxWidget();
    3. pWindow->setControl( "HKEY_CLASSES_ROOT\\TypeLib\\{ACFC5869-1D0F-4E2C-B898-05805607D542}" );
    4.  
    5. setCentralWidget( pWindow );
    To copy to clipboard, switch view to plain text mode 

    but I have
    Qt Code:
    1. QAxBase::setControl: requested control HKEY_CLASSES_ROOT\TypeLib\{ACFC5869-1D0F-4E2C-B898-05805607D542} could not be instantiated
    To copy to clipboard, switch view to plain text mode 
    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()?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QAxWidget - my controler could not be instantiated

    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:

    Qt Code:
    1. pWindow->setControl( "Excel.Workspace" );
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. pWindow->setControl( "{00020820-0000-0000-C000-000000000046}" );
    To copy to clipboard, switch view to plain text mode 

    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.

  3. #3
    Join Date
    Dec 2012
    Posts
    13
    Thanks
    1

    Default Re: QAxWidget - my controler could not be instantiated

    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.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QAxWidget - my controler could not be instantiated

    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.

Similar Threads

  1. QAxWidget and C#
    By vxmontes in forum Newbie
    Replies: 0
    Last Post: 3rd August 2011, 15:52
  2. Replies: 4
    Last Post: 28th March 2011, 16:29
  3. Access instantiated objects from C++
    By Sunny31 in forum Qt Quick
    Replies: 3
    Last Post: 5th December 2010, 17:25
  4. ActiveQt : requested control could not be instantiated
    By zirconius in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2010, 13:27
  5. QAxWidget
    By ToddAtWSU in forum Newbie
    Replies: 2
    Last Post: 3rd February 2006, 17:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.