Results 1 to 1 of 1

Thread: Accessing a QAxObject* from IDispatch* problem

  1. #1
    Join Date
    Dec 2009
    Location
    Romania, Iasi
    Posts
    18
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Accessing a QAxObject* from IDispatch* problem

    Hello fellows,

    I've been trying to solve an issue related to ActiveQt and COM objects for many hours, but still didn't found an answer to it. Would be nice to have some help from more experienced people with ActiveQt framework.
    Here is the problem ... I have an external COM/dll on which I was using the dumpcpp tool to generate the .h and .cpp files.

    This was my command: dumpcpp "C:\Program Files\CQG\CQGNet\Bin\CQGCEL-4_0.dll" -o CQGCEL-4_0

    Next thing I was trying to treat in my SLOT(onSignal(QString,int,void*)) something that is emitted from the standard SIGNAL(signal(const QString&,int,void*)):

    Qt Code:
    1. CQG_Tester::CQG_Tester() : cqgObj(new CQGCEL(this)) // cqgObj is a QAxObject from the external library.
    2. {
    3. [COLOR="#FF8C00"]connect(cqgObj, SIGNAL(signal(const QString&,int,void*)), SLOT(onSignal(QString,int,void*)));[/COLOR]
    4. connect(cqgObj, SIGNAL(CELStarted()), SLOT(requestDataSources()));
    5. connect(cqgObj, SIGNAL(OnIdle()), SLOT(OnIdle()));
    6. connect(cqgObj, SIGNAL(LineTimeChanged(const QDateTime&)), SLOT(LineTimeChanged(const QDateTime&)));
    7. connect(cqgObj, SIGNAL(propertyChanged(const QString&)), SLOT(onPropertyChanged(QString)));
    8. connect(cqgObj, SIGNAL(exception(int,const QString&,const QString&,const QString&)), SLOT(onException(int,QString,QString,QString)));
    9.  
    10. cqgObj->Startup();
    11. }
    To copy to clipboard, switch view to plain text mode 

    My onSignal SLOT looks like this:

    Qt Code:
    1. void CQG_Tester::onSignal(const QString & name, int argc, void * argv)
    2. {
    3. VARIANTARG *params = (VARIANTARG*)argv;
    4. if(name == "InstrumentDOMChanged(IDispatch*,IDispatch*,IDispatch*)") {
    5.  
    6. IDispatch * instrument_disp = params[argc-1].pdispVal;
    7. //instrument_disp->AddRef(); [B]// LINE A[/B]
    8.  
    9. ICQGInstrument instrument(instrument_disp, cqgObj); // QAxObject from the external COM/dll
    10.  
    11. for(int i = 0; i < 2; ++i) {
    12.  
    13. ICQGDOMQuotes * dom = (i == 0 ? instrument.DOMAsks() : instrument.DOMBids()); // QAxObject from the external COM/dll
    14.  
    15. cout << (i == 0 ? "Asks: " : "Bids: ");
    16.  
    17. const int count = dom->Count();
    18. for(int j = 0; j < count; ++j) {
    19. ICQGQuote * quote = dom->Item(j);
    20. cout << quote->Price() << ',' << quote->Volume() << ';';
    21. }
    22. }
    23. cout << endl;
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    As you can see in the code right above I'm trying to instantiate and use a QAxObject via a pointer to IDispatch*. From some reasons after the control flow leaves the onSignal method the application crashes somewhere in the imported dll.
    But ... if I de-comment LINE A (instrument_disp->AddRef()) the program works fine, but it seems this produces a memory leak, because the memory used increases rapidly as this method is called very frequent.
    There is also another strange internal Qt's debug message: Object::receivers: No such signal CQG::CQGCEL::InstrumentDOMChanged(IDispatch*,IDisp atch*,IDispatch*)
    First of all I don't know why such a signal would not exist. I thought dumpcpp should handle properly this aspect since IDispatch* is a type supported by ActiveQt. Documentation says it is equivalent to an QAxObject*. It also seems that in the generated .cpp file the signal's signature is the following: InstrumentDOMChanged(ICQGInstrument*,ICQGDOMQuotes *,ICQGDOMQuotes*) which seems to be correct according to the library's documentation. Why would all three parameter types would have changed to IDispatch* while trying to emit somewhere the signal?
    Also, I tried in onSignal() method to cast directly an IDispatch* object to an QAxObject*, but this seems NOT to work.

    I have a feeling I'm missing a very little point, but hard for me to find out. Can anybody help on this please?

    Many thanks in advance,
    Victor
    Last edited by vcernobai; 26th January 2012 at 19:56.

Similar Threads

  1. Get the iDispatch interface of an ActiveX control
    By punkypogo in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2010, 08:00
  2. Replies: 8
    Last Post: 23rd July 2010, 08:53
  3. Replies: 0
    Last Post: 1st May 2010, 12:41
  4. QCachece accessing problem
    By rajini333 in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2009, 19:15
  5. QVariant to QAxObject*
    By QDrow in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2008, 09:35

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.