Posts Qt Jambi
Post
Cancel

Qt Jambi

references http://github.com/xbacinsk/MZJ_Timetable/tree/master/src/timetabler http://github.com/markholland/QTJambi-Text-Editor http://zetcode.com/gui/qtjambi/dialogs/ snippets - http://gist.github.com/jewelsea FileDrop for native controls - http://iharder.sourceforge.net/current/java/filedrop/

Qt is a multiplatform C++ GUI development framework. For java developers who like Qt and don’t like Swing programs’ look in Linux, Qt Jambi could be a good choice. It hasn’t been developed as long as Qt but Trolltech’s sites claim it provides all the functionality of Qt. Yes, QT Jambi is a QT Binding to Java, allowing you to develop QT GUI using Java instead of C++.

Qt Jambi is the Qt library made available to Java. It is an open source technology aimed at all desktop programmers wanting to write rich GUI clients using the Java language, while at the same time taking advantage of Qt’s power and efficiency.

http://qtjambi.org/ http://sourceforge.net/projects/qtjambi/

warning x64 users - download x86 flavor

-All C++ Qt libs exist to C:\qtjambi-4.8.6\lib (if you get errors copy *.ddls to PATH)

-open C:\qtjambi-4.8.6\designer.bat create a GUI -save the form as *.jui -use C:\qtjambi-4.8.6\bin\juic.exe as ‘juic.exe Ui_Dialog.jui’, this will generate the Ui_Dialog.java

-Open NetBeans JavaSE > Create new Project -reference the lib C:\qtjambi-4.8.6\qtjambi-4.8.6.jar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//this is the main application form into, save it to Ui_MainApplication.java
import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;

public class Ui_MainApplication implements com.trolltech.qt.QUiForm<qmainwindow> {

    public QAction action_New;
    public QAction action_Open;

    public QMenu menu_File;
    public QMenu menu_About;

    public QToolBar toolBar;

    public Ui_MainApplication() {
        super();
    }

    public void setupUi(QMainWindow MainApplication) {
        MainApplication.setObjectName("MainApplication");
        MainApplication.resize(new QSize(800, 600).expandedTo(MainApplication.minimumSizeHint()));

//SETUP TOOLBAR
        action_New = new QAction(MainApplication);
        action_New.setObjectName("action_New");
        action_New.setIcon(new QIcon(new QPixmap("classpath:icons/New_48x48.png")));

        action_Open = new QAction(MainApplication);
        action_Open.setObjectName("action_Open");
        action_Open.setIcon(new QIcon(new QPixmap("classpath:icons/Open_48x48.png")));

        toolBar = new QToolBar(MainApplication);
        toolBar.setObjectName("toolBar");
        MainApplication.addToolBar(com.trolltech.qt.core.Qt.ToolBarArea.TopToolBarArea, toolBar);

        toolBar.addAction(action_New);
        toolBar.addSeparator();
        toolBar.addAction(action_Open);
//SETUP TOOLBAR

        retranslateUi(MainApplication);

        MainApplication.connectSlotsByName();
    } // setupUi

    void retranslateUi(QMainWindow MainApplication) {
        MainApplication.setWindowTitle(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "Test Window", null));
        action_New.setText(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "&New", null));
        action_New.setToolTip(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "Create a new document", null));
        action_New.setShortcut(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "Ctrl+N", null));

        action_Open.setText(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "&Open...", null));
        action_Open.setToolTip(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "Open an existing document", null));
        action_Open.setShortcut(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "Ctrl+O", null));

        toolBar.setWindowTitle(com.trolltech.qt.core.QCoreApplication.translate("MainApplication", "toolBar", null));
    } // retranslateUi
}

//save the main application from into Ui_MainApplication_code.java
import com.trolltech.qt.gui.QDialog;
import com.trolltech.qt.gui.QFileDialog;
import com.trolltech.qt.gui.QMainWindow;
import com.trolltech.qt.gui.QMessageBox;

public class Ui_MainApplication_code extends QMainWindow {

    private Ui_MainApplication ui = new Ui_MainApplication();

    public Ui_MainApplication_code() {

        ui.setupUi(this);

        ui.action_New.triggered.connect(this, "show_jui_form()");
        ui.action_Open.triggered.connect(this, "show_cmd()");
    }

    public void show_jui_form() {
        //show JUI form

        Ui_Dialog_code dialog = new Ui_Dialog_code();
        if (dialog.exec() == QDialog.DialogCode.Rejected.value()) {

            QMessageBox.information(this, "Info", "JUI Form cancelled");
            dialog.close();
            return;
        }

        QMessageBox.information(this, "Info", "JUI Form accepted");
        dialog.close();
    }

    public void show_cmd() {
        //show common dialog
        String fileName = QFileDialog.getOpenFileName(this, tr("Open file"), ".", new QFileDialog.Filter(tr("XML files (*.xml)")));
        if (fileName == null || fileName.isEmpty()) {
            return;
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//save to Ui_Dialog.java (this generated by QtJambi)
import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;

public class Ui_Dialog implements com.trolltech.qt.QUiForm<qdialog>
{
    public QDialogButtonBox buttonBox;

    public Ui_Dialog() { super(); }

    public void setupUi(QDialog Dialog)
    {
        Dialog.setObjectName("Dialog");
        Dialog.resize(new QSize(600, 418).expandedTo(Dialog.minimumSizeHint()));
        buttonBox = new QDialogButtonBox(Dialog);
        buttonBox.setObjectName("buttonBox");
        buttonBox.setGeometry(new QRect(240, 380, 341, 32));
        buttonBox.setOrientation(com.trolltech.qt.core.Qt.Orientation.Horizontal);
        buttonBox.setStandardButtons(com.trolltech.qt.gui.QDialogButtonBox.StandardButton.createQFlags(com.trolltech.qt.gui.QDialogButtonBox.StandardButton.Cancel,com.trolltech.qt.gui.QDialogButtonBox.StandardButton.Ok));
        retranslateUi(Dialog);
        buttonBox.accepted.connect(Dialog, "accept()");
        buttonBox.rejected.connect(Dialog, "reject()");

        Dialog.connectSlotsByName();
    } // setupUi

    void retranslateUi(QDialog Dialog)
    {
        Dialog.setWindowTitle(com.trolltech.qt.core.QCoreApplication.translate("Dialog", "Dialog", null));
    } // retranslateUi

}

//save to Ui_Dialog_code.java
import com.trolltech.qt.gui.QDialog;

public class Ui_Dialog_code extends QDialog {

    private Ui_Dialog ui = new Ui_Dialog();

    public Ui_Dialog_code() {
        ui.setupUi(this);
    }

}

dont forget are your friend

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//the JavaApplication1.java (entry point)
//http://stackoverflow.com/q/14786760

public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        final QApplication app = new QApplication(args);

        Ui_MainApplication_code mainForm  = new Ui_MainApplication_code();
        mainForm.show();

        app.exec();
    }

}

write to log : System.out.println(“pipiscrew”);</qdialog></qmainwindow>

origin - http://www.pipiscrew.com/?p=2915 java-qt-jambi

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags