Qt Jambi 项目本身带了支持 Eclipse 的插件，可在 Eclipse 环境中直接访问 Qt Jambi 的文档和 Qt 设计器，目前支持 Windows 和 Linux 系统。
- 创建 Qt Jambi 项目
在 Eclipse 中使用 Qt 设计器
- Java User Interface Compiler
Qt Jambi 的 Eclipse 集成插件，要求至少 Eclipse 3.2 或者更高的版本，然后需要 Qt Jambi 的二进制包。
首先解压 Qt Jambi 到 Eclipse 的目录，然后使用 --clean 参数来启动 Eclipse（只是第一次需要这样）。
Note that we have experienced problems on some KDE systems where GTK is set to use the same style as KDE. You will need to disable this option in order to use the Qt Jambi Eclipse Integration. On some distributions, the style can be changed by opening the Settings menu, selecting the Appearance submenu, move on to GTK styles and fonts, and finally select Use another style.
Before you can start using the Qt Jambi plugin, you must specify the location of your Qt Jambi installation: Open the Qt Jambi section in Preferences, and hit the Browse button in order to locate the folder containing the installation. When you have located the correct directory, hit the Validate button to check that Qt Jambi has been installed properly. After setting the location of Qt Jambi, you may have to restart Eclipse in order for the Jambi plugins to be loaded properly.
The plugin will automatically generate Java classes for forms edited with Qt Designer. By default, the generated files will be located in a separate source folder in your project. Use the Qt Jambi preferences to alter this location.
Note that the same preferences can be set on a per-project basis: Just select Properties for your project and find the Qt Jambi page. Using the project properties, you may also disable and enable the Juic Builder, the tool generating the Java classes from the Qt Designer forms.
创建 Qt Jambi 项目
To create a new Qt Jambi project, you simply select New Project in the File menu. Then select the Qt Jambi Project (Using Designer Form) option from the Qt Jambi folder and click the Next button. If you want to create a without a designer form, you can select Qt Jambi Project.
This will open a wizard guiding you through the steps of creating a new Qt Jambi project. Most of these are identical to the steps you take to create ordinary Java projects. Then, in the end, you will be asked for the name and package of the main class in your application, and for the layout of the application's main window.
When you have entered this information, click the Finish button to add the project to your workspace. Provided that you have set the correct path to your Qt Jambi installation (see the previous section for details), the project will have the correct build path settings for using the Qt Jambi classes and for running your application from within the Eclipse environment.
在 Eclipse 中使用 Qt 设计器
By default, Qt Designer's property editor and widget box are not shown within the Eclipse environment, i.e., they must be explicitly enabled by the user. This can be done by selecting Show View from the Windows menu and Other from the entry's submenu.
Then a dialog box where it is possible to select and enable the different Qt Designer components, will appear.
For your convenience, the Qt Jambi plugin also comes with a user interface perspective, which opens the Qt Designer views for you: Select the Open Perspective entry in the Window menu. Then select the Qt Designer UI perspective from the Other... entry's submenu.
To create a new .jui file with Qt Designer go into the File menu and select New and then Other, as shown in the screenshot below.
This will pop up a dialog allowing you to select a wizard:
Choose the Qt Designer Form from the Qt Jambi directory and click Next. This will bring up a dialog box to query for the file name and location as shown in the screenshot below:
In addition to the many standard widgets found in the Qt Designer widget box, you can also add your own custom widgets and use them in your application.
The first step is to add a QWidget subclass to your project. In addition, it is required that custom widgets have a constructor that takes a single QWidget argument as its parent.
After the widget has been created, open the properties of your project and select the Qt Designer Plugins page. This page will list the candidates for custom widgets in your project, and the list will indicate whether the widget meets the criteria for being a custom widget. In order to become a custom widget the class has to be a subclass of QWidget and it needs to have a constructor that takes a QWidget argument.
In the above example, we are adding the customwidgets.MyOwnCustomWidget widget to the widget box. The widget is part of the project and contains a layout with a QLabel, which contains the text "Hello World".
When you have added a custom widget to a project, it will show up in the widget box under a heading with the same name as the project. The widget box will only contain custom widgets for the current project (i.e., the project to which the .jui file that is edited belongs).
To use the custom widget, click and drag into your form like any other.
Note that to avoid problems, you should always remove a widget from the custom widgets before deleting it from a project. If you change the widget's code after it has been added to a project, the widget might not be immediately updated in designer; you may have to restart Eclipse for the changes to be visible in the editor.
Java User Interface Compiler
Qt Jambi comes with a Java user interface compiler (JUIC), a tool that produces Qt Jambi source code from user interface definition files (.jui files). JUIC is integrated into the Eclipse IDE as a custom build tool that will update all source files whenever the .jui files are changed (note that it is executed prior to the Eclipse built-in incremental builder which means that all source code is guaranteed to be up to date after a editing a form in Qt Designer).
Qt Jambi provides a uniform syntax for accessing resources in the Java classpath, no matter whether they are located directly on the disk or in a JAR bundle. Resources are identified by a classpath: prefix.
If you have set the correct path to Qt Jambi in your preferences, the resource editor will be populated with images collected from the source folders of your project. You can add search paths by right clicking in the editor and selecting Edit Search Path entry in the context menu.
When you, for example, want to put an image onto a label or a button, you will be able to select it from the resource editor. Provided that the classpath contains the folder in which the image was found, the correct path and prefix will be set automatically in the generated file.