Sophie

Sophie

distrib > * > 2009.0 > i586 > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 309

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/qt-4.3/doc/src/designer-manual.qdoc -->
<head>
  <title>Using Custom Widgets with Qt Designer</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1 align="center">Using Custom Widgets with Qt Designer<br /><small></small></h1>
<p><i>Qt Designer</i> can display custom widgets through its extensible plugin mechanism, allowing the range of designable widgets to be extended by the user and third parties. This feature also allows <i>Qt Designer</i> to optionally support Qt 3 compatibility widgets</tt>. Alternatively, it is possible to use existing widgets as placeholders for widget classes that provide similar APIs.</p>
<ul><li><a href="#handling-custom-widgets">Handling Custom Widgets</a></li>
<ul><li><a href="#promoting-widgets">Promoting Widgets</a></li>
<li><a href="#user-defined-custom-widgets">User Defined Custom Widgets</a></li>
</ul>
</ul>
<p>Widgets from the Qt3Support library are made available via in <i>Qt Designer</i>'s support for custom widgets.</p>
<a name="handling-custom-widgets"></a>
<h2>Handling Custom Widgets</h2>
<p>Although <i>Qt Designer</i> supports all of the standard Qt widgets, and can be configured to handle widgets supplied in the Qt3Support library, some specialized widgets may not be available as standard for a number of reasons:</p>
<ul>
<li>Custom widgets may not be available at the time the user interface is being designed.</li>
<li>Custom widgets may be platform-specific, and designers may be developing the user interface on a different platform to end users.</li>
<li>The source code for a custom widget is not available, or the user interface designers are unable to use the widget for non-technical reasons.</li>
</ul>
<p>In the above situations, it is still possible to design forms with the aim of using custom widgets in the application. To achieve this, we can use the widget promotion feature of <i>Qt Designer</i>.</p>
<p>In all other cases, where the source code to the custom widgets is available, we can adapt the custom widget for use with <i>Qt Designer</i>.</p>
<a name="promoting-widgets"></a>
<h3>Promoting Widgets</h3>
<p align="center"><img src="images/designer-promoting-widgets.png" /></p><p>In the case where forms must be designed, but where certain custom widgets are unavailable to the designer, we can substitute similar widgets to represent the missing widgets. For example, we might represent instances of a custom push button class, <tt>MyPushButton</tt>, with instances of <a href="gui/QPushButton.html"><tt>QPushButton</tt></a> and promote these to <tt>MyPushButton</tt> so that <a href="uic.html">uic</tt></a> generates suitable code for this missing class.</p>
<p>When choosing a widget to use as a placeholder, it is useful to compare the API of the missing widget with those of standard Qt widgets. For specialized widgets that subclass standard classes, the obvious choice of placeholder is the base class of the custom widget; for example, <a href="gui/QSlider.html"><tt>QSlider</tt></a> might be used for specialized <a href="gui/QSlider.html"><tt>QSlider</tt></a> subclasses.</p>
<p>For specialized widgets that do not share a common API with standard Qt widgets, it is worth considering adapting a custom widget for use in <i>Qt Designer</i>. If this is not possible then <a href="gui/QWidget.html"><tt>QWidget</tt></a> is the obvious choice for a placeholder widget since it is the lowest common denominator for all widgets.</p>
<p>To add a placeholder, select an object of a suitable base class and choose <b>Promote to ..&#x2e;</b> from the form's context menu. After entering the class name and header file in the lower part of the dialog, choose <b>Add</b>. The placeholder class will now appear along with the base class in the upper list. Click the <b>Promote</b> button to accept this choice.</p>
<p>Now, when the form's context menu is opened over objects of the base class, the placeholder class will appear in the <b>Promote to</b> submenu, allowing for convenient promotion of objects to that class.</p>
<p>A promoted widget can be reverted to its base class by choosing <b>Demote to</b> from the form's context menu.</p>
<a name="user-defined-custom-widgets"></a>
<h3>User Defined Custom Widgets</h3>
<p align="center"><img src="images/worldtimeclockplugin-example.png" /></p><p>Custom widgets can be adapted for use with <i>Qt Designer</i>, giving designers the opportunity to configure the user interface using the actual widgets that will be used in an application rather than placeholder widgets.</p>
<p>The process of creating a custom widget plugin is described in the <a href="designer-creating-custom-widgets.html">Creating Custom Widgets for Qt Designer</tt></a> chapter of this manual.</p>
<p>To use a plugin created in this way, it is necessary to ensure that it is located on a path that <i>Qt Designer</i> searches for plugins. Generally, plugins stored in <tt>$QTDIR/plugins/designer</tt> will be loaded when <i>Qt Designer</i> starts.</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>