~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/designer-using-custom-widgets.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/designer-manual.qdoc -->
 
6
<head>
 
7
    <title>Qt 4.0: Using Custom Widgets with Qt Designer</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
    <link rel="prev" href="designer-resources.html" />
 
15
    <link rel="contents" href="designer-manual.html" />
 
16
    <link rel="next" href="designer-using-a-component.html" />
 
17
</head>
 
18
<body>
 
19
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
20
<tr>
 
21
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
22
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
23
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><p>
 
24
[Previous: <a href="designer-resources.html">Editing Resources with Qt Designer</a>]
 
25
[<a href="designer-manual.html">Contents</a>]
 
26
[Next: <a href="designer-using-a-component.html">Using a Component in Your Application</a>]
 
27
</p>
 
28
<h1 align="center">Using Custom Widgets with Qt Designer</h1>
 
29
<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 <a href="qt3support.html">Qt 3 compatibility widgets</a>. Alternatively, it is possible to use existing widgets as placeholders for widget classes that provide similar APIs.</p>
 
30
<ul><li><a href="#handling-custom-widgets">Handling Custom Widgets</a></li>
 
31
<ul><li><a href="#promoting-widgets">Promoting Widgets</a></li>
 
32
<li><a href="#user-defined-custom-widgets">User Defined Custom Widgets</a></li>
 
33
</ul>
 
34
</ul>
 
35
<p>Widgets from the <a href="qt3support.html#qt3support">Qt3Support</a> library are made available via in <i>Qt Designer</i>'s support for custom widgets.</p>
 
36
<a name="handling-custom-widgets"></a>
 
37
<h2>Handling Custom Widgets</h2>
 
38
<p>Although <i>Qt Designer</i> supports all of the standard Qt widgets, and can be configured to handle widgets supplied in the <a href="qt3support.html#qt3support">Qt3Support</a> library, some specialized widgets may not be available as standard for a number of reasons:</p>
 
39
<ul>
 
40
<li>Custom widgets may not be available at the time the user interface is being designed.</li>
 
41
<li>Custom widgets may be platform-specific, and designers may be developing the user interface on a different platform to end users.</li>
 
42
<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>
 
43
</ul>
 
44
<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>
 
45
<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>
 
46
<a name="promoting-widgets"></a>
 
47
<h3>Promoting Widgets</h3>
 
48
<center><img src="images/designer-promoting-widgets.png" /></center><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="qpushbutton.html">QPushButton</a> and promote these to <tt>MyPushButton</tt> so that <a href="uic.html">uic</a> generates suitable code for this missing class.</p>
 
49
<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="qslider.html">QSlider</a> might be used for specialized <a href="qslider.html">QSlider</a> subclasses.</p>
 
50
<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="qwidget.html">QWidget</a> is the obvious choice for a placeholder widget since it is the lowest common denominator for all widgets.</p>
 
51
<a name="user-defined-custom-widgets"></a>
 
52
<h3>User Defined Custom Widgets</h3>
 
53
<center><img src="images/customwidgetplugin-example.png" /></center><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>
 
54
<p>The process of creating a custom widget plugin is described in the <a href="designer-customwidgetplugin.html">Custom Widget Plugin</a> example. To use a plugin, 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>
 
55
<p>
 
56
[Previous: <a href="designer-resources.html">Editing Resources with Qt Designer</a>]
 
57
[<a href="designer-manual.html">Contents</a>]
 
58
[Next: <a href="designer-using-a-component.html">Using a Component in Your Application</a>]
 
59
</p>
 
60
<p /><address><hr /><div align="center">
 
61
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
62
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
63
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
64
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
65
</tr></table></div></address></body>
 
66
</html>