?? designer-manual-4.html
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/tools/designer/book/chap-philosophy.leaf:3 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>The Designer Approach</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><p align="right">[<a href="designer-manual-3.html">Prev: Creating Main Windows with Actions, Toolbars and Menus</a>] [<a href="designer-manual.html">Home</a>] [<a href="designer-manual-5.html">Next: Subclassing and Dynamic Dialogs</a>]</p><h2 align="center">The Designer Approach</h2><h3><a name="1"></a>Introduction</h3><p>In Qt 2.x, <em>Qt Designer</em> was a visual form designer for editing files in the <tt>.ui</tt> file format. <em>Qt Designer</em>'s primary goal was to turn the most tedious part of GUI programming -- dialog design -- into a pleasant experience. From an architectural point of view, <em>Qt Designer</em> in 2.x is a fairly simple program. It reads and writes <tt>.ui</tt> files. Each <tt>.ui</tt> file contains an XML description of a single dialog form. A second utility -- the user interface compiler <tt>uic</tt> -- is used during the build process of an application to generate C++ code from those XML descriptions.</p><p>For Qt 3.0 our ambitions for <em>Qt Designer</em> have grown beyond single dialog editing. In addition to many new design features like the ability to creating main windows and actions, the new version introduces:</p><ul><li><p><em>project management</em> for the user interface part of your application;</p><li><p><em>code in forms</em> <em>Qt Designer</em> provides a code editor so that you can code your slots directly; the code is stored in <tt>.ui.h</tt> files and eliminates the need for sub-classing (although you can still subclass if you prefer);</p><li><p><em>dynamic form loading</em> allows you to load <tt>.ui</tt> files at runtime which provides great scope for design customisation separate from the underlying code.</p></ul><p>The purpose of this chapter is to explain the motivation for making these changes, describe the new concepts involved and show how these features work internally.</p><p><em>Qt Designer</em> is and remains a visual design tool: it is not a complete integrated development environment. Our policy is to make GUI development as easy and powerful as possible without locking our users into any particular tool: <em>Qt Designer</em> makes it easy to create and modify GUI designs, but you can still achieve the same results directly in code using a plain text editor if you prefer.</p><p>To make working more convenient, <em>Qt Designer</em> now includes a C++ editor (as a plugin). If you want to create or edit a form, use <em>Qt Designer</em>. If you want edit code for that form, you can use the C++ editor in <em>Qt Designer</em> as well. This built-in editor has certain benefits stemming from its tight integration with the visual form design process that we will explain later. However, if you prefer using the editor you're used to, <tt>vim</tt>, <tt>emacs</tt>, <tt>notepad</tt>, Microsoft Visual Studio, etc. you can still do so.</p><h3><a name="2"></a>Project management</h3><p>Reading and writing single, non-connected <tt>.ui</tt> files is conceptually simple and worked fairly well in Qt 2.x. However, it lacked certain features that made us introduce project management for the GUI part of an application in <em>Qt Designer</em>. The main benefits of project management are:</p><ul><li><p>Grouping forms that belong together.</p><li><p>Sharing images between different forms.</p><li><p>Sharing database information between different forms.</p></ul><p>The following sections explain these benefits in more detail, and why project management is required to achieve them.</p><h4><a name="2-1"></a>Grouping forms</h4><p>Grouping forms means that <em>Qt Designer</em> maintains a list of the <tt>.ui</tt> files that belong to the same project. This makes it easy to switch between forms with a single mouse click.</p><h4><a name="2-2"></a>Sharing images in a image collection</h4><p>In Qt 2.x's <em>Qt Designer</em> each form included the images it required and no images were shared. This led to duplication when several forms needed to use the same images. Furthermore the images were stored in the XML <tt>.ui</tt> files which made them large.</p><p>As a workaround, we introduced a pixmap-loading function that you could define in <em>Qt Designer</em>. It then was your responsibility to provide the implementation of this function in your application code. The big disadvantage of this approach was that you couldn't see the images during the design process in <em>Qt Designer</em>. This not only makes designing a form less visually interesting, but also has a noticeable impact on geometry management.</p><p>In the Qt 3.0 version of <em>Qt Designer</em> we've introduced the concept of a project image collection. If you use a project you can add images to the project's image collection, and these images can be shared and used by any of the forms you include in the project. The images are stored as PNGs (portable network graphics) in a subdirectory, <tt>images/</tt>, inside the project's directory. Whenever you modify the image collection, <em>Qt Designer</em> creates a source file which contains both the image data in binary format and a function to instantiate the images. The images are accessible by all forms in the project and the data is shared.</p><p>A further benefit of using an image collection is that the images are added to the default QMimeSourceFactory. This way they are accessible from rich-text labels, What's This? context help and even tooltips through standard HTML image tags. The <em>source</em> argument of the image tag is simply the image's name in the image collection. This also works during the design process in <em>Qt Designer</em>.</p><h4><a name="2-3"></a>Sharing database settings</h4>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -