Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 2356

qtjambi-doc-4.3.3-3mdv2008.1.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /home/gvatteka/dev/qtjambi/4.3/scripts/../doc/src/qtjambi-eclipse.qdoc -->
<head>
  <title>Qt Jambi Eclipse Integration</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1 align="center">Qt Jambi Eclipse Integration<br /><small></small></h1>
<p>Qt Jambi comes with a plugin for the Eclipse IDE, providing access to the Qt Jambi documentation and Qt Designer from within the Eclipse environment. The integration is currently supported on Windows and Linux. In addition, Mac OS X support is under development.</p>
<ul><li><a href="#installation">Installation</a></li>
<li><a href="#preferences">Preferences</a></li>
<li><a href="#creating-qt-jambi-projects">Creating Qt Jambi Projects</a></li>
<li><a href="#using-qt-designer-within-eclipse">Using Qt Designer within Eclipse</a></li>
<ul><li><a href="#creating-new-forms">Creating New Forms</a></li>
<li><a href="#adding-custom-widgets">Adding Custom Widgets</a></li>
<li><a href="#the-java-user-interface-compiler">The Java User Interface Compiler</a></li>
</ul>
<li><a href="#adding-resources">Adding Resources</a></li>
</ul>
<a name="installation"></a>
<h2>Installation</h2>
<p>To install the Qt Jambi plugin, you need the Qt Jambi Eclipse Integration package. This is a <tt>.zip</tt> file for Windows and a <tt>.tar.gz</tt> file for Linux. They contain the Eclipse plugins and the native libraries required to run Qt Designer.</p>
<p>Unpack the package in the Eclipse root folder, and then run Eclipse with the <tt>-clean</tt> command line option (it is only required to do this once). On Windows, you also need to run the <tt>register_eclipse_integration.bat</tt> file to complete the installation.</p>
<p>The Qt Jambi Integration requires Eclipse version 3.2 or higher. Note that we have experienced problems using KDE with Qt3. If you need to do this, you should not use the GTK Style. The style can be changed by opening the <b>Settings</b> menu, selecting the <b>Appearance</b> submenu, move on to <b>GTK styles and fonts</b>, and finally select <b>Use another style</b>.</p>
<a name="preferences"></a>
<h2>Preferences</h2>
<p>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 <b>Preferences</b>, and hit the <b>Browse</b> button in order to locate the folder containing the installation. When you have located the correct directory, hit the <b>Validate</b> 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.</p>
<p align="center"><img src="images/eclipse-settings.png" /></p><p>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.</p>
<p>Note that the same preferences can be set on a per-project basis: Just select <b>Properties</b> 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.</p>
<a name="creating-qt-jambi-projects"></a>
<h2>Creating Qt Jambi Projects</h2>
<p>To create a new Qt Jambi project, you simply select <b>New</b> Project in the <b>File</b> menu. Then select the <b>Qt Jambi Gui Project</b> option from the Qt Jambi folder and click the <b>Next</b> button.</p>
<p>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.</p>
<p align="center"><img src="images/eclipse-select-template.png" /></p><p>When you have entered this information, click the <b>Finish</b> 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.</p>
<a name="using-qt-designer-within-eclipse"></a>
<h2>Using Qt Designer within Eclipse</h2>
<p>By default, Qt Designer's property editor and widget box are not shown within the Eclipse environment, i.e&#x2e;, they must be explicitly enabled by the user. This can be done by selecting <b>Show View</b> from the <b>Windows</b> menu and <b>Other</b> from the entry's submenu.</p>
<p align="center"><img src="images/eclipse-window-others.png" /></p><p>Then a dialog box where it is possible to select and enable the different Qt Designer components, will appear.</p>
<p align="center"><img src="images/eclipse-window-show-view.png" /></p><p>For your convenience, the Qt Jambi plugin also comes with a user interface perspective, which opens the Qt Designer views for you: Select the <b>Open Perspective</b> entry in the <b>Window</b> menu. Then select the <b>Qt Designer UI</b> perspective from the <b>Other..&#x2e;</b> entry's submenu.</p>
<a name="creating-new-forms"></a>
<h3>Creating New Forms</h3>
<p>To create a new <tt>.jui</tt> file with Qt Designer go into the <b>File</b> menu and select <b>New</b> and then <b>Other</b>, as shown in the screenshot below.</p>
<p align="center"><img src="images/eclipse-file-new.png" /></p><p>This will pop up a dialog allowing you to select a wizard:</p>
<p align="center"><img src="images/eclipse-form-wizard.png" /></p><p>Choose the <b>Qt Designer Form</b> from the <b>Qt Jambi</b> directory and click <b>Next</b>. This will bring up a dialog box to query for the file name and location as shown in the screenshot below:</p>
<p align="center"><img src="images/eclipse-create-form.png" /></p><a name="adding-custom-widgets"></a>
<h3>Adding Custom Widgets</h3>
<p>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.</p>
<p>The first step is to add a <tt>QWidget</tt> subclass to your project. In addition, it is required that custom widgets have a constructor that takes a single <tt>QWidget</tt> argument as its parent.</p>
<p>After the widget has been created, open the properties of your project and select the <b>Qt Designer Plugins</b> 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 <tt>QWidget</tt> and it needs to have a constructor that takes a <tt>QWidget</tt> argument.</p>
<p align="center"><img src="images/eclipse-custom-widget-add.png" /></p><p>In the above example, we are adding the <tt>customwidgets.MyOwnCustomWidget</tt> widget to the widget box. The widget is part of the project and contains a layout with a <a href="gui/QLabel.html"><tt>QLabel</tt></a>, which contains the text &quot;Hello World&quot;.</p>
<p>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&#x2e;, the project to which the .jui file that is edited belongs).</p>
<p align="center"><img src="images/eclipse-custom-widget-select.png" /></p><p>To use the custom widget, click and drag into your form like any other.</p>
<p align="center"><img src="images/eclipse-custom-widget.png" /></p><p>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.</p>
<a name="the-java-user-interface-compiler"></a>
<h3>The Java User Interface Compiler</h3>
<p>Qt Jambi comes with a Java user interface compiler (JUIC), a tool that produces Qt Jambi source code from user interface definition files (<tt>.jui</tt> files). JUIC is integrated into the Eclipse IDE as a custom build tool that will update all source files whenever the <tt>.jui</tt> 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).</p>
<a name="adding-resources"></a>
<h2>Adding Resources</h2>
<p>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 <tt>classpath</tt>: prefix.</p>
<p align="center"><img src="images/eclipse-resource-editor.png" /></p><p>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 <b>Edit Search Path</b> entry in the context menu.</p>
<p>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.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2007 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Jambi </div></td>
</tr></table></div></address></body>
</html>