2 messages in net.java.dev.jna.usersRe: [jna-users] Has anyone tried usin...
FromSent OnAttachments
David GoodenoughMar 10, 2009 3:06 am 
Daniel KaufmannMar 11, 2009 9:28 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Has anyone tried using JNA to talk to Qt?Actions...
From:Daniel Kaufmann (dani@gmail.com)
Date:Mar 11, 2009 9:28:09 pm
List:net.java.dev.jna.users

Qt seems to be a C++ library. JNA is not provide facilities to call C++ code, just C code, so you will need to write a C wrapper for the library, in order to use just plain functions instead of classes and objects and then use JNA to call the C function.For example: class A { public: int getVal(char b); } would become extern "C" { int getVal(A *a, char b); } You need to actually implement the C like function, not just declare it. Also be aware that the function names in C can't be overloaded, so you need to give each function a different name, even if they are overloaded in the same class. The same needs to be done for every method, constructor and operator needed. For a big library like Qt it will be a lot of work.

Other libraries might allow better integration between java and C++ although generally they generate C/C++ code that you need to compile in every platform.

Anyway it looks like QtJambi will be available as LGPL so it might be continue to be supported by the community even that it is not supported officially by Qt.

Daniel

On Tue, Mar 10, 2009 at 7:07 AM, David Goodenough < davi@linkchoose.co.uk> wrote:

I notice that Nokia/Trolltech have announced that 4.5 is to be the last formally supported version of QtJambi. So the questions is where do we go for Java support of Qt? It occured to me that JNA might be useable but I wondered if anyone has actually tried it? If so did it work, and was it easy to use?