source: trunk/doc/html/qtoolbar.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 12.5 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qtoolbar.cpp:210 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QToolBar Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QToolBar Class Reference</h1>
33
34<p>The QToolBar class provides a movable panel containing
35widgets such as tool buttons.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qtoolbar-h.html">qtoolbar.h</a>&gt;</tt>
38<p>Inherits <a href="qdockwindow.html">QDockWindow</a>.
39<p><a href="qtoolbar-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn>QToolBar ( const&nbsp;QString&nbsp;&amp;&nbsp;label, QMainWindow *, ToolBarDock = DockTop, bool&nbsp;newLine = FALSE, const&nbsp;char&nbsp;*&nbsp;name = 0 ) &nbsp;<em>(obsolete)</em></li>
43<li class=fn><a href="#QToolBar-2"><b>QToolBar</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;label, QMainWindow&nbsp;*&nbsp;mainWindow, QWidget&nbsp;*&nbsp;parent, bool&nbsp;newLine = FALSE, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )</li>
44<li class=fn><a href="#QToolBar-3"><b>QToolBar</b></a> ( QMainWindow&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
45<li class=fn>void <a href="#addSeparator"><b>addSeparator</b></a> ()</li>
46<li class=fn>QMainWindow * <a href="#mainWindow"><b>mainWindow</b></a> () const</li>
47<li class=fn>virtual void <a href="#setStretchableWidget"><b>setStretchableWidget</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
48<li class=fn>virtual void <a href="#setLabel"><b>setLabel</b></a> ( const QString &amp; )</li>
49<li class=fn>QString <a href="#label"><b>label</b></a> () const</li>
50<li class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</li>
51</ul>
52<h2>Properties</h2>
53<ul>
54<li class=fn>QString <a href="#label-prop"><b>label</b></a>&nbsp;- the toolbar's label</li>
55</ul>
56<hr><a name="details"></a><h2>Detailed Description</h2>
57
58
59The QToolBar class provides a movable panel containing
60widgets such as tool buttons.
61<p>
62
63<p> A toolbar is a panel that contains a set of controls, usually
64represented by small icons. It's purpose is to provide quick
65access to frequently used commands or options. Within a
66<a href="qmainwindow.html">QMainWindow</a> the user can drag toolbars within and between the
67<a href="qdockarea.html">dock areas</a>. Toolbars can also be dragged
68out of any dock area to float freely as top-level windows.
69<p> QToolBar is a specialization of <a href="qdockwindow.html">QDockWindow</a>, and so provides all
70the functionality of a QDockWindow.
71<p> To use QToolBar you simply create a QToolBar as a child of a
72QMainWindow, create a number of <a href="qtoolbutton.html">QToolButton</a> widgets (or other
73widgets) in left to right (or top to bottom) order and call
74<a href="#addSeparator">addSeparator</a>() when you want a separator. When a toolbar is
75floated the caption used is the label given in the constructor
76call. This can be changed with <a href="#setLabel">setLabel</a>().
77<p>
78
79<pre> QToolBar * fileTools = new QToolBar( this, "file operations" );
80 fileTools-&gt;<a href="#setLabel">setLabel</a>( "File Operations" );
81 fileOpenAction-&gt;<a href="qaction.html#addTo">addTo</a>( fileTools );
82 fileSaveAction-&gt;<a href="qaction.html#addTo">addTo</a>( fileTools );
83</pre>
84<p> This extract from the <a href="simple-application-example.html">application/application.cpp</a> example shows
85the creation of a new toolbar as a child of a <a href="qmainwindow.html">QMainWindow</a> and
86adding two QActions.
87<p> You may use most widgets within a toolbar, with QToolButton and
88<a href="qcombobox.html">QComboBox</a> being the most common.
89<p> If you create a new widget on an already visible QToolBar, this
90widget will automatically become visible without needing a <a href="qwidget.html#show">show</a>()
91call. (This differs from every other Qt widget container. We
92recommend calling show() anyway since we hope to fix this anomaly
93in a future release.)
94<p> QToolBars, like QDockWindows, are located in <a href="qdockarea.html">QDockArea</a>s or
95float as top-level windows. QMainWindow provides four QDockAreas
96(top, left, right and bottom). When you create a new toolbar (as
97in the example above) as a child of a QMainWindow the toolbar will
98be added to the top dock area. You can move it to another dock
99area (or float it) by calling <a href="qmainwindow.html#moveDockWindow">QMainWindow::moveDockWindow</a>(). QDock
100areas lay out their windows in <a href="qdockarea.html#lines">Lines</a>.
101<p> If the main window is resized so that the area occupied by the
102toolbar is too small to show all its widgets a little arrow button
103(which looks like a right-pointing chevron, '&#187;') will appear
104at the right or bottom of the toolbar depending on its
105orientation. Clicking this button pops up a menu that shows the
106'overflowing' items. QToolButtons are represented in the menu using
107their textLabel property, other <a href="qbutton.html">QButton</a> subclasses are represented
108using their text property, and QComboBoxes are represented as submenus,
109with the caption text being used in the submenu item.
110<p> Usually a toolbar will get precisely the space it needs. However,
111with <a href="qdockwindow.html#setHorizontalStretchable">setHorizontalStretchable</a>(), <a href="qdockwindow.html#setVerticalStretchable">setVerticalStretchable</a>() or
112<a href="#setStretchableWidget">setStretchableWidget</a>() you can tell the main window to expand the
113toolbar to fill all available space in the specified orientation.
114<p> The toolbar arranges its buttons either horizontally or vertically
115(see <a href="qdockwindow.html#orientation">orientation</a>() for details). Generally, <a href="qdockarea.html">QDockArea</a> will set the
116orientation correctly for you, but you can set it yourself with
117<a href="qdockwindow.html#setOrientation">setOrientation</a>() and track any changes by connecting to the
118<a href="qdockwindow.html#orientationChanged">orientationChanged</a>() signal.
119<p> You can use the <a href="#clear">clear</a>() method to remove all items from a toolbar.
120<p> <center><img src="qdockwindow.png" alt="Toolbar (dock window)"></center> <blockquote><p align="center"><em> A floating QToolbar (dock window)
121</em></p>
122</blockquote><p> <p>See also <a href="qtoolbutton.html">QToolButton</a>, <a href="qmainwindow.html">QMainWindow</a>, <a href="http://www.iarchitect.com/visual.htm">Parts of Isys on Visual Design</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Tool Bar</a>, and <a href="application.html">Main Window and Related Classes</a>.
123
124<hr><h2>Member Function Documentation</h2>
125<h3 class=fn><a name="QToolBar"></a>QToolBar::QToolBar ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, <a href="qmainwindow.html">QMainWindow</a>&nbsp;*, ToolBarDock = DockTop, bool&nbsp;newLine = FALSE, const&nbsp;char&nbsp;*&nbsp;name = 0 )
126</h3>
127
128<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
129<p>
130<h3 class=fn><a name="QToolBar-2"></a>QToolBar::QToolBar ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, <a href="qmainwindow.html">QMainWindow</a>&nbsp;*&nbsp;mainWindow, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, bool&nbsp;newLine = FALSE, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )
131</h3>
132Constructs an empty horizontal toolbar.
133<p> The toolbar is called <em>name</em> and is a child of <em>parent</em> and is
134managed by <em>mainWindow</em>. The <em>label</em> and <em>newLine</em> parameters
135are passed straight to <a href="qmainwindow.html#addDockWindow">QMainWindow::addDockWindow</a>(). <em>name</em> and
136the widget flags <em>f</em> are passed on to the <a href="qdockwindow.html">QDockWindow</a> constructor.
137<p> Use this constructor if you want to create torn-off (undocked,
138floating) toolbars or toolbars in the <a href="qstatusbar.html">status
139 bar</a>.
140
141<h3 class=fn><a name="QToolBar-3"></a>QToolBar::QToolBar ( <a href="qmainwindow.html">QMainWindow</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
142</h3>
143This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
144<p> Constructs an empty toolbar called <em>name</em>, with parent <em>parent</em>,
145in its <em>parent</em>'s top dock area, without any label and without
146requiring a newline.
147
148<h3 class=fn>void <a name="addSeparator"></a>QToolBar::addSeparator ()
149</h3>
150Adds a separator to the right/bottom of the toolbar.
151
152<p>Examples: <a href="canvas-chart-example.html#x2894">chart/chartform.cpp</a>, <a href="fileiconview-example.html#x895">fileiconview/mainwindow.cpp</a>, <a href="helpviewer-example.html#x1033">helpviewer/helpwindow.cpp</a>, <a href="qfd-example.html#x2010">qfd/fontdisplayer.cpp</a>, and <a href="scribble-example.html#x943">scribble/scribble.cpp</a>.
153<h3 class=fn>void <a name="clear"></a>QToolBar::clear ()<tt> [virtual]</tt>
154</h3>
155Deletes all the toolbar's child widgets.
156
157<h3 class=fn><a href="qstring.html">QString</a> <a name="label"></a>QToolBar::label () const
158</h3><p>Returns the toolbar's label.
159See the <a href="qtoolbar.html#label-prop">"label"</a> property for details.
160<h3 class=fn><a href="qmainwindow.html">QMainWindow</a>&nbsp;* <a name="mainWindow"></a>QToolBar::mainWindow () const
161</h3>
162Returns a pointer to the <a href="qmainwindow.html">QMainWindow</a> which manages this toolbar.
163
164<h3 class=fn>void <a name="setLabel"></a>QToolBar::setLabel ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
165</h3><p>Sets the toolbar's label.
166See the <a href="qtoolbar.html#label-prop">"label"</a> property for details.
167<h3 class=fn>void <a name="setStretchableWidget"></a>QToolBar::setStretchableWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
168</h3>
169Sets the widget <em>w</em> to be expanded if this toolbar is requested
170to stretch.
171<p> The request to stretch might occur because <a href="qmainwindow.html">QMainWindow</a>
172right-justifies the dock area the toolbar is in, or because this
173toolbar's <a href="qdockwindow.html#isVerticalStretchable">isVerticalStretchable</a>() or <a href="qdockwindow.html#isHorizontalStretchable">isHorizontalStretchable</a>() is
174set to TRUE.
175<p> If you call this function and the toolbar is not yet stretchable,
176setStretchable() is called.
177<p> <p>See also <a href="qmainwindow.html#rightJustification-prop">QMainWindow::rightJustification</a>, <a href="qdockwindow.html#setVerticalStretchable">setVerticalStretchable</a>(), and <a href="qdockwindow.html#setHorizontalStretchable">setHorizontalStretchable</a>().
178
179<p>Examples: <a href="fileiconview-example.html#x896">fileiconview/mainwindow.cpp</a> and <a href="helpviewer-example.html#x1034">helpviewer/helpwindow.cpp</a>.
180<hr><h2>Property Documentation</h2>
181<h3 class=fn><a href="qstring.html">QString</a> <a name="label-prop"></a>label</h3>
182<p>This property holds the toolbar's label.
183<p>If the toolbar is floated the label becomes the toolbar window's
184caption. There is no default label text.
185
186<p>Set this property's value with <a href="#setLabel">setLabel</a>() and get this property's value with <a href="#label">label</a>().
187<!-- eof -->
188<hr><p>
189This file is part of the <a href="index.html">Qt toolkit</a>.
190Copyright &copy; 1995-2007
191<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
192<table width=100% cellspacing=0 border=0><tr>
193<td>Copyright &copy; 2007
194<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
195<td align=right><div align=right>Qt 3.3.8</div>
196</table></div></address></body>
197</html>
Note: See TracBrowser for help on using the repository browser.