- Published on
Using QtJambi on Windows
- Authors

- Name
- Daisuke Kobayashi
- https://twitter.com
These are my notes from trying Qt Jambi.
I am not very good at GUI work. If I am going to spend time on it, I would rather learn something that I can apply to other languages as well, so I chose QtJambi. Development does not seem to have been very active for the past several years, but I tried it anyway.
Installation
Download and install the Windows 32bit 4.8.5-beta4 version from here.
Write a main like this.
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QPushButton;
public class Main {
public static void main(String[] args) {
QApplication.initialize(args);
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
hello.setWindowTitle("Hello World");
hello.show();
QApplication.execStatic();
}
}
Copy qtjambi-4.8.5.jar and qtjambi-native-win32-mingw-4.8.5.jar from the installation folder into the current directory, then run the commands below from the command line.
jar cvf Main.jar *.class $ java -cp qtjambi-4.8.5.jar;qtjambi-native-win32-mingw-4.8.5.jar;Main.jar Main
Create a project for IntelliJ
Create a project that can be imported from IntelliJ. The folder structure should look like this.
QtJambiTest --- lib --- qtjambi-4.8.5.jar
| +- qtjambi-native-win32-mingw-4.8.5.jar
|
+- project --- plugins.sbt
|
+- src --- main --- java --- Main.java
|
+- build.sbt
Add the following to project/plugins.sbt.
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
Write build.sbt like this.
name := "QtJambiTest"
version := "0.0.1"
scalaVersion := "2.11.2"
libraryDependencies ++= Seq(
)
Then run the following command from the command line to create the IntelliJ project.
$ sbt gen-idea
You should then be able to run the program from the generated project.
Generate source code from a .ui file created in Qt Designer
You can generate source code from a .ui file with the steps below, but some functionality does not seem to be supported. I saw warnings for enum-related parameters.
- Rename
*.uito*.jui - Open the UI file and remove
<?xml version="1.0" encoding="UTF-8"?> - Remove the blank line at the top
- Change
<ui version="4.0">to<ui version="4.0" language="jambi"> - Run
juic -cp .