Results 1 to 5 of 5

Thread: (ActiveQt) Invoking interface from COM object

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default (ActiveQt) Invoking interface from COM object

    Hi, I am trying to invoke an interface from COM object installed as a component service in windows by using the following code:

    Qt Code:
    1. #include <ActiveQt/QAxObject>
    2. #include <ActiveQt/QAxWidget>
    3. #include <QUuid>
    4. #include <objbase.h>
    5. #include <unknwn.h>
    6. #include "ui_qt1.h"
    7.  
    8. class MainWindow: public QMainWindow
    9. {
    10. public:
    11. MainWindow(QString & str);
    12. };
    13.  
    14. MainWindow::MainWindow(QString & str)
    15. {
    16. Ui::Window ui;
    17. ui.setupUi(this);
    18. ui.lineEdit->setText(str);
    19. }
    20.  
    21. int main(int argc, char ** argv)
    22. {
    23. QApplication a(argc, argv);
    24. QAxObject component1;
    25. component1.setControl("{DEE370B4-933F-49F6-858C-26D028319C3F}");
    26.  
    27. void** interface1;
    28. HRESULT hr;
    29.  
    30. IUnknown *iface=0;
    31. hr=component1.queryInterface(IID_IUnknown,(void**)&iface);
    32.  
    33. QString str;
    34.  
    35. if(iface)
    36. {
    37. iface->Release();
    38. str="Interface supported";
    39. }
    40. else
    41. {
    42. str="NoT supported";
    43. }
    44.  
    45. MainWindow w(str);
    46. w.show();
    47. return a.exec();
    48. }
    To copy to clipboard, switch view to plain text mode 

    And in my project I am in the end displaying the QString str. Everytime it is displaying "Not supported" which means that I am not getting even the IUnknown interface from the component, which is strange as every Component must have an IUnknown interface.

    Can anyone help me getting this interface from the component?

    Thanks,

    Mridul
    Last edited by wysota; 19th May 2009 at 08:29. Reason: missing [code] tags

Similar Threads

  1. Replies: 12
    Last Post: 22nd March 2009, 11:22
  2. Replies: 4
    Last Post: 19th February 2009, 11:10
  3. ActiveQt: How to pass image to ActiveX object?
    By AndreasSchlempp in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2009, 12:44
  4. Help with Q_PROPERTY with object pointer
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 17:31

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.