[Android-development] QStringList to Java Array?
Stromme Christian
Christian.Stromme at digia.com
Tue Sep 23 11:56:17 CEST 2014
On 22 Sep 2014, at 12:35 , Harri Pasanen <harri at mpaja.com> wrote:
> Hi,
>
> I wonder if there are any helper classes to convert from
>
> QStringList to [Ljava/lang/String
>
> (and back)?
>
> I assume this is my JNI noobness talking, but to me it looks as obvious
> as coming up with a grammatically correct phrase in German.
>
> Thanks,
>
> Harri
>
>
> _______________________________________________
> Android-development mailing list
> Android-development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/android-development
Hi,
The only way to convert between an object array of Strings and QStringList is to do it manually, that is, iterate through the list/array and copy the string.
For iterating through the object array, see GetObjectArrayElement() and GetArrayLength()[1] (accessible through the QAndroidJniEnvironment class)
An easier way, if you can change the java function (or write a wrapper), is to make the java function return the string-array as one string and then call split on the QString :)
[1]http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#wp17314
—
Christian
More information about the Android-development
mailing list