Last active
February 20, 2024 10:25
-
-
Save vascorsd/1ae097030f51da40007ab74505d148da to your computer and use it in GitHub Desktop.
Scala GUI using QT on linux / archlinux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using scala 3.3.1 | |
//> using platform jvm | |
// docs say that QtJambi runs on jvm 8 or later. My system has jvm 21 installed. | |
//> using jvm system | |
// --- QT6 | UI toolkit configuration on linux / archlinux | |
//> using dep io.qtjambi:qtjambi:6.6.1 | |
//> using dep io.qtjambi:qtjambi-native-linux-x64:6.6.1 | |
// not strictly needed since the default search path includes this path, | |
// but let's make it explicit for now. It's where the native Qt libraries are looked for. | |
//> using javaProp java.library.path=/usr/lib | |
// --- end QT6 | |
import io.qt.widgets.*; | |
@main | |
def helloWorldWindow(args: String*) = { | |
println("hi") | |
QApplication.initialize(args.toArray) | |
QMessageBox.information(null, "QtJambi", "Hello World!") | |
QApplication.shutdown() | |
println("bye") | |
} |
Ran on scala-cli at the following version:
❯ scala-cli --version
Scala CLI version: 1.1.2
Scala version (default): 3.3.1
Save the file locally and run with:
❯ scala-cli run .
Output should be the following:
❯ scala-cli run .
Compiling project (Scala 3.3.1, JVM (system))
Compiled project (Scala 3.3.1, JVM (system))
hi
# window shows up here according to the above screenshot. After closing the next message appears.
bye
Even more crazy, I think you can run the scala-cli pointing directly to this gist url and it runs accordingly:
❯ scala-cli run https://gist.github.com/vascorsd/1ae097030f51da40007ab74505d148da
Compiling project (Scala 3.3.1, JVM (system))
Compiled project (Scala 3.3.1, JVM (system))
hi
bye
But I wouldn't recommend anyone doing that, since I can just change the gist to become malicious 😈
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm surprised it works.
Specially since I really thought QtJambi was dead but looking at https://github.com/OmixVisualization/qtjambi it actually has activity and already is available to use with QT6 which I already have the libraries around in my system 🥳