Results 1 to 3 of 3

Thread: Active Qt. Objects that imported from VirtualBox.tlb could not be instantiated

  1. #1
    Join Date
    Jan 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Active Qt. Objects that imported from VirtualBox.tlb could not be instantiated

    Hi Qt Funs!

    I have started developing on Qt this week and second day as I stopped on binging VirtualBox COM API to Active Qt.

    VirtualBoxClient is created well by non-Active Qt, classic way:
    Qt Code:
    1. ...
    2. #include "d:\sources\algorithms\comtest2\comtest2\debug\virtualbox.tlh"
    3. ...
    4. CLSIDFromProgID(OLESTR("VirtualBox.VirtualBoxClient"), &clsid);
    5. IVirtualBoxClient *virtualBoxClient = nullptr;
    6. hr = CoCreateInstance(clsid, nullptr, CLSCTX_INPROC_SERVER, __uuidof(IVirtualBoxClient), (void**)&virtualBoxClient);
    7. if (FAILED(hr) || virtualBoxClient == nullptr) {
    8. ...
    To copy to clipboard, switch view to plain text mode 

    But how to do it in Qt style? Step by step:
    1) The following lines are added to a project file:
    QT += widgets axcontainer
    TYPELIBS = $$system(dumpcpp VirtualBox.tlb -n vbox )
    vbox.h and vbox.cpp are generated without an error.
    2) lines in main.cpp:
    Qt Code:
    1. #include "vbox.h"
    2.  
    3. using namespace vbox;
    4.  
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QCoreApplication a(argc, argv);
    9. vbox::VirtualBox v ;
    10. qDebug() << v.isNull();
    11. vbox::VirtualBoxClient client;
    12. qDebug() << client.isNull();
    To copy to clipboard, switch view to plain text mode 
    Output:
    CoCreateInstance failure (CoInitialize has not been called.)
    QAxBase::setControl: requested control {b1a7a4f2-47b9-4a1e-82b2-07ccd5323c3f} could not be instantiated
    true
    CoCreateInstance failure (CoInitialize has not been called.)
    QAxBase::setControl: requested control {dd3fc71d-26c0-4fe1-bf6f-67f633265bba} could not be instantiated
    true

    Could you show me the right way?
    Attached Files Attached Files
    Last edited by minskster; 13th January 2017 at 17:14.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,017
    Thanks
    280
    Thanked 816 Times in 805 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Active Qt. Objects that imported from VirtualBox.tlb could not be instantiated

    CoCreateInstance failure (CoInitialize has not been called.)
    Read the error message. You need to call CoInitialize() in your code -before- trying to instantiate a COM object. If you look at your "classic way" code, you'll see the call there, too.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Active Qt. Objects that imported from VirtualBox.tlb could not be instantiated

    From my reading of http://doc.qt.io/qt-5/activeqt-container.html
    Qt Code:
    1. QT += axcontainer
    2. TYPELIBS = VirtualBox.tlb
    3. HEADERS += ...
    4. SOURCES += ...
    To copy to clipboard, switch view to plain text mode 
    and let qmake organise running dumpcpp.

    If you want the namespace vbox then you might need to run dumpcpp once and manually add the two output files to HEADERS and SOURCES and omit the TYPELIBS

Similar Threads

  1. QAxWidget - my controler could not be instantiated
    By ArnaudC in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2013, 18:33
  2. VirtualBox compiling is %100 safe
    By selametting in forum Newbie
    Replies: 2
    Last Post: 17th August 2012, 07:38
  3. Replies: 4
    Last Post: 28th March 2011, 16:29
  4. Access instantiated objects from C++
    By Sunny31 in forum Qt Quick
    Replies: 3
    Last Post: 5th December 2010, 17:25
  5. ActiveQt : requested control could not be instantiated
    By zirconius in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2010, 13:27

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.