PDA

View Full Version : use a COM ( or a .Net ) object in a c++ QT application



franco.amato
8th April 2010, 23:29
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

arpspatel
9th April 2010, 02:15
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...

franco.amato
9th April 2010, 03:07
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

arpspatel
9th April 2010, 03:33
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



#include <QString>

#using <mscorlib.dll>
#include <vcclr.h>

using namespace System;

String *QStringToString(const QString &qstring)
{
return new String((const wchar_t *)qstring.utf16());
}

QString StringToQString(String *string)
{
const wchar_t __pin *chars = PtrToStringChars(string);
return QString::fromWCharArray(chars);
}



use can also use QLibrary for loading dlls, not sure if it will work for .NET or COM.. give it a try..

franco.amato
9th April 2010, 03:41
My problem is the inverse.
I would use a COM object in a C++ program

franco.amato
13th April 2010, 17:59
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



#include <QString>

#using <mscorlib.dll>
#include <vcclr.h>

using namespace System;

String *QStringToString(const QString &qstring)
{
return new String((const wchar_t *)qstring.utf16());
}

QString StringToQString(String *string)
{
const wchar_t __pin *chars = PtrToStringChars(string);
return QString::fromWCharArray(chars);
}



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:


code for load com/.net dll


get routine pointers


call routine myroutine(param1, param2) with param 1 and 2

Is too difficult to provide a simple example?

vxmontes
3rd August 2011, 20:19
Hi,

I have the same problem, looking for a simple example

Vitor