Kotlin in QT Project. How?
-
From the looks of if Kotlin is to replace Java, so you likely have to look into the direction of JNI.
-
@bogong said in Kotlin in QT Project. How?:
I want to add Kotlin class into QT Project and seeking solution.
Ask the Kotlin community if there is a way to call Kotlin code from C++ code. If it exists, then you can use Kotlin in Qt. If it doesn't exist, then you're out of luck.
Qt is a C++ library (mostly).
Also, which platforms do you plan to target? Windows/Linux/Android/...?
-
@bogong said in Kotlin in QT Project. How?:
I am seeking solution for implementing Kotlin into Qt for Android and build it automatically like I am doing right now with Java
And why can't you ask such a precise question from the beginning? I asked you two times to give a better description of you task, but you refused up to now.
So it seems the answer is currently: NO.
Regards
-
@aha_1980 It seems you only DO NOT know answer. There are solution to use Kotlin in C++ and it's in official Kotlin doc. It's making through plain C wrapper. Natively Kotlin support Objective-C and plain C. And you have to build Kotlin part like shared object for Android or static lib for iOS and then within wrapper written on Objective-C/CPP or plain C add it to CPP project that might be using in Android or iOS application. I just been seeking in-box solution in Qt (because there are global troubles in compilers, you have to build it separately and wrap it into plain C or in Java and then to use it through JNI - this way haven't tested it yet) and the question was super clear: "Is there any way to add Kotlin in QT Project?" - It was my first question. In return you asked me not about details, you asked me about WHY I need this ... I've been 2 times explaining to you what I need. And now you writing me "And why can't you ask such a precise question from the beginning?" - really???
Issue closed ...
-
@sgaist Directly it's not possible because of compilers, there need to be built Kotlin first on native compiler like *.so, after it wrap it into Java and after add all of it into Qt. But this way haven't tested by me yet. It's only theory.
-
This topic is quite old but I thought I would answer it for others that might think about using Kotlin in Qt projects.
You can do it (at least for Android) via JNI! See this presentation from QtWS21: https://www.youtube.com/watch?v=nmvurCcsWos&t=50s
-
You can use Qt in Java (so also in Kotlin) using QtJambi.
I made the application Mouse Melon with Kotlin and Qt.