jstring -> type name / unexpected expression
-
wrote on 8 Nov 2023, 20:46 last edited by
Hello there,
am trying to call a static Java method which takes a string as argument.
QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object()<jstring>());
I´m getting the error "unexpected type name 'jstring': expected expression" and can´t figure out, if I´m missing to include a library or something else.
Has someone an idea?
-
Hello there,
am trying to call a static Java method which takes a string as argument.
QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object()<jstring>());
I´m getting the error "unexpected type name 'jstring': expected expression" and can´t figure out, if I´m missing to include a library or something else.
Has someone an idea?
wrote on 8 Nov 2023, 22:41 last edited byI think the last line is a little too parentheses-heavy:
QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object<jstring>());
-
I think the last line is a little too parentheses-heavy:
QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object<jstring>());
wrote on 9 Nov 2023, 07:04 last edited by Flaming Moe 11 Sept 2023, 07:04@ChrisW67
There is one thing i´m defenetly doing wrong I see now - the 'I' behind the
(Ljava/lang/String;)
is wrong, since I call a void-return method.QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object()<jstring>());
May be there is a flaw in the example .
In the c-code part of the following is a comma after the method name "fromNumber"// C++ code QJniObject stringNumber = QJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass", "fromNumber", "(I)Ljava/lang/String;", 10);
while here isn´t a comma after "stringArray"
// C++ code QJniObject string1 = QJniObject::fromString("String1"); QJniObject string2 = QJniObject::fromString("String2"); QJniObject stringArray = QJniObject::callStaticObjectMethod<jstringArray>( "org/qtproject/qt/TestClass", "stringArray" string1.object<jstring>(), string2.object<jstring>());
-
@ChrisW67
There is one thing i´m defenetly doing wrong I see now - the 'I' behind the
(Ljava/lang/String;)
is wrong, since I call a void-return method.QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object()<jstring>());
May be there is a flaw in the example .
In the c-code part of the following is a comma after the method name "fromNumber"// C++ code QJniObject stringNumber = QJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass", "fromNumber", "(I)Ljava/lang/String;", 10);
while here isn´t a comma after "stringArray"
// C++ code QJniObject string1 = QJniObject::fromString("String1"); QJniObject string2 = QJniObject::fromString("String2"); QJniObject stringArray = QJniObject::callStaticObjectMethod<jstringArray>( "org/qtproject/qt/TestClass", "stringArray" string1.object<jstring>(), string2.object<jstring>());
wrote on 9 Nov 2023, 08:42 last edited by@Flaming-Moe Yes, that is a missing comma in the documentation. Feel free to raise a bug if you cannot find it already reported.
-
-
@Flaming-Moe Yes, that is a missing comma in the documentation. Feel free to raise a bug if you cannot find it already reported.
wrote on 10 Nov 2023, 14:04 last edited by@ChrisW67 Even after your former post I haven´t noticed the wrong paranthesis after my ".object" until yesterday evening after staring at goats for a loooong time
1/5