Results 1 to 7 of 7

Thread: use a COM ( or a .Net ) object in a c++ QT application

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default use a COM ( or a .Net ) object in a c++ QT application

    Hi to all I have a problem.
    I have to build a program in C++ with Qt and I have to use some routines contained in a dll.
    I have to version of the same dll
    • com version
    • .net version


    I would know how to use the routines in my qt application. I read about ActiveQt but I'm not sure is what I need.
    And which version of the dll can I use? The COM or the .net version?

    Regards
    Franco Amato

  2. #2
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use a COM ( or a .Net ) object in a c++ QT application

    you can use both .net and com version.. I dont know much about this, you can try looking into the examples provided in the Qt Installation. There are many examples, one such for COM version and also for .NET. They can provide more information about this.. try Qt Assistant which comes with Qt SDK, it has detail explanation of the coding for the examples and maybe on how to do what you are asking for...

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use a COM ( or a .Net ) object in a c++ QT application

    Quote Originally Posted by arpspatel View Post
    you can use both .net and com version.. I dont know much about this, you can try looking into the examples provided in the Qt Installation. There are many examples, one such for COM version and also for .NET. They can provide more information about this.. try Qt Assistant which comes with Qt SDK, it has detail explanation of the coding for the examples and maybe on how to do what you are asking for...
    I read the assistant and I gave a look at the example but I can not find for example the point where it load the dll

  4. #4
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use a COM ( or a .Net ) object in a c++ QT application

    for loading dll u can use this.. its used in .NET activeQt example

    #using <dllname.dll>

    http://doc.qt.nokia.com/4.6/activeqt-dotnet.html

    here is sample code from the example

    Qt Code:
    1. #include <QString>
    2.  
    3. #using <mscorlib.dll>
    4. #include <vcclr.h>
    5.  
    6. using namespace System;
    7.  
    8. String *QStringToString(const QString &qstring)
    9. {
    10. return new String((const wchar_t *)qstring.utf16());
    11. }
    12.  
    13. QString StringToQString(String *string)
    14. {
    15. const wchar_t __pin *chars = PtrToStringChars(string);
    16. return QString::fromWCharArray(chars);
    17. }
    To copy to clipboard, switch view to plain text mode 

    use can also use QLibrary for loading dlls, not sure if it will work for .NET or COM.. give it a try..
    Last edited by arpspatel; 9th April 2010 at 03:37.

  5. #5
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use a COM ( or a .Net ) object in a c++ QT application

    My problem is the inverse.
    I would use a COM object in a C++ program

  6. #6
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use a COM ( or a .Net ) object in a c++ QT application

    Quote Originally Posted by arpspatel View Post
    for loading dll u can use this.. its used in .NET activeQt example

    #using <dllname.dll>

    http://doc.qt.nokia.com/4.6/activeqt-dotnet.html

    here is sample code from the example

    Qt Code:
    1. #include <QString>
    2.  
    3. #using <mscorlib.dll>
    4. #include <vcclr.h>
    5.  
    6. using namespace System;
    7.  
    8. String *QStringToString(const QString &qstring)
    9. {
    10. return new String((const wchar_t *)qstring.utf16());
    11. }
    12.  
    13. QString StringToQString(String *string)
    14. {
    15. const wchar_t __pin *chars = PtrToStringChars(string);
    16. return QString::fromWCharArray(chars);
    17. }
    To copy to clipboard, switch view to plain text mode 

    use can also use QLibrary for loading dlls, not sure if it will work for .NET or COM.. give it a try..
    Hi I'm trying your suggestion but I still don't understand how to get the pointer of the dll routines and call them.
    Why there is no a simple and clear example?

    as this:

    Qt Code:
    1. code for load com/.net dll
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. get routine pointers
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. call routine myroutine(param1, param2) with param 1 and 2
    To copy to clipboard, switch view to plain text mode 

    Is too difficult to provide a simple example?
    Franco Amato

  7. #7
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: use a COM ( or a .Net ) object in a c++ QT application

    Hi,

    I have the same problem, looking for a simple example

    Vitor

Similar Threads

  1. Getting std::string object from QString object ( qt3)
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2013, 20:09
  2. writing object to the file(Object Persistance)
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 14:28
  3. How to know the object names of any generic application ?
    By soumyadeep_pan in forum Qt Programming
    Replies: 2
    Last Post: 5th May 2009, 07:11
  4. Open a QMainWindow Object in QDialog Object
    By chuengchuenghq in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 06:33
  5. Application very heavy for lots object
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 29th April 2006, 17:33

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.