Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, December 2006
Qwt?


Message 1 in thread

Hello,

Would it be possible to wrap popular Qt based libraries like Qwt to 
Jambi with the generator? For instance QwtArrayData
(http://qwt.sourceforge.net/class_qwt_array_data.html) takes two 
pointers to double for the initialization, how would this be
wrapped to Java code?

Best regards,
Helge Fredriksen


Message 2 in thread

Helge Fredriksen wrote:
> Hello,
> 
> Would it be possible to wrap popular Qt based libraries like Qwt to 
> Jambi with the generator? 

Hi Helge,

We haven't explicitly tried Qwt, but it should be possible.

 > For instance QwtArrayData
> (http://qwt.sourceforge.net/class_qwt_array_data.html) takes two 
> pointers to double for the initialization, how would this be
> wrapped to Java code?

You would use QNativePointer for this. QNativePointer is when pointer 
types arise in C++ that can not be represented in Java. You would create 
an array type native pointer (with size) and initialize it with our 
data. Something along the lines of:

// Construct the double * of size xArray.length
QNativePointer x =
   new QNativePointer(QNativePointer.Type.Double, xArray.length);

// Copy the data over...
for (int i = 0; i<xArray.length; ++i)
     x.setDoubleAt(i, xArray[i]);

// Similar for y
QwtArrayData data = new QwtArrayData(x, y, size);

---

The native array is memory managed by the GC so you need to keep a 
reference to x for the lifetime of data. Alternativly, if data takes 
ownership of the native memory, you can disable the memory management of 
the array by calling:

setAutoDeleteMode(QNativePointer.AutoDeleteMode.None);

-
best regards,
Gunnar