Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
platform
samples
src
LICENSE.FDL
LICENSE.GPLv2
LICENSE.GPLv3
LICENSE.LGPLv21
LICENSE.LGPLv3
LICENSE.QT-LICENSE-AGREEMENT-4.0
README.md
cppbuild.sh
pom.xml

README.md

JavaCPP Presets for Qt

Introduction

This directory contains the JavaCPP Presets module for:

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.

Documentation

Java API documentation is available here:

∗ Call Loader.load(QtCore.class) to get the path for -platformpluginpath before using this API.
∗ Java must be started with the '-XstartOnFirstThread' command-line option on macOS.

Sample Usage

Here is a simple example of Qt ported to Java from this C++ source file:

We can use Maven 3 to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the pom.xml and GettingStarted.java source files below, simply execute on the command line:

 $ mvn compile exec:java

Please see the samples directory for more Qt examples ported to Java from C++.

The pom.xml build file

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.bytedeco.qt</groupId>
    <artifactId>gettingstarted</artifactId>
    <version>1.5-SNAPSHOT</version>
    <properties>
        <exec.mainClass>GettingStarted</exec.mainClass>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>qt-platform</artifactId>
            <version>5.12.2-1.5-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>.</sourceDirectory>
    </build>
</project>

The GettingStarted.java source file

import java.io.File;
import org.bytedeco.javacpp.*;
import org.bytedeco.qt.QtCore.*;
import org.bytedeco.qt.QtGui.*;
import org.bytedeco.qt.QtWidgets.*;
import static org.bytedeco.qt.global.QtCore.*;
import static org.bytedeco.qt.global.QtGui.*;
import static org.bytedeco.qt.global.QtWidgets.*;

public class GettingStarted {
    private static IntPointer argc;
    private static PointerPointer argv;

    public static void main(String[] args) {
        String path = Loader.load(org.bytedeco.qt.global.QtCore.class);
        argc = new IntPointer(new int[]{3});
        argv = new PointerPointer("gettingstarted", "-platformpluginpath", new File(path).getParent(), null);

        QApplication app = new QApplication(argc, argv);

        QTextEdit textEdit = new QTextEdit();
        textEdit.show();

        System.exit(app.exec());
    }
}
You can’t perform that action at this time.