summaryrefslogtreecommitdiffstats
path: root/doc/html/qtoolbar.html
blob: b74ab21b793560923d18f67eb8981dafa6122e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qtoolbar.cpp:210 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QToolBar Class</title>
<style type="text/css"><!--
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&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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><h1 align=center>QToolBar Class Reference</h1>

<p>The QToolBar class provides a movable panel containing
widgets such as tool buttons.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qtoolbar-h.html">qtoolbar.h</a>&gt;</tt>
<p>Inherits <a href="qdoctwindow.html">QDockWindow</a>.
<p><a href="qtoolbar-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<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>
<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>
<li class=fn><a href="#QToolBar-3"><b>QToolBar</b></a> ( QMainWindow&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn>void <a href="#addSeparator"><b>addSeparator</b></a> ()</li>
<li class=fn>QMainWindow * <a href="#mainWindow"><b>mainWindow</b></a> () const</li>
<li class=fn>virtual void <a href="#setStretchableWidget"><b>setStretchableWidget</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
<li class=fn>virtual void <a href="#setLabel"><b>setLabel</b></a> ( const QString &amp; )</li>
<li class=fn>QString <a href="#label"><b>label</b></a> () const</li>
<li class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>QString <a href="#label-prop"><b>label</b></a>&nbsp;- the toolbar's label</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QToolBar class provides a movable panel containing
widgets such as tool buttons.
<p> 

<p> A toolbar is a panel that contains a set of controls, usually
represented by small icons. It's purpose is to provide quick
access to frequently used commands or options. Within a
<a href="qmainwindow.html">QMainWindow</a> the user can drag toolbars within and between the
<a href="qdockarea.html">dock areas</a>. Toolbars can also be dragged
out of any dock area to float freely as top-level windows.
<p> QToolBar is a specialization of <a href="qdoctwindow.html">QDockWindow</a>, and so provides all
the functionality of a QDockWindow.
<p> To use QToolBar you simply create a QToolBar as a child of a
QMainWindow, create a number of <a href="qtoolbutton.html">QToolButton</a> widgets (or other
widgets) in left to right (or top to bottom) order and call
<a href="#addSeparator">addSeparator</a>() when you want a separator. When a toolbar is
floated the caption used is the label given in the constructor
call. This can be changed with <a href="#setLabel">setLabel</a>().
<p> 

<pre>        QToolBar * fileTools = new QToolBar( this, "file operations" );
        fileTools-&gt;<a href="#setLabel">setLabel</a>( "File Operations" );
        fileOpenAction-&gt;<a href="qaction.html#addTo">addTo</a>( fileTools );
        fileSaveAction-&gt;<a href="qaction.html#addTo">addTo</a>( fileTools );
</pre>
<p> This extract from the <a href="simple-application-example.html">application/application.cpp</a> example shows
the creation of a new toolbar as a child of a <a href="qmainwindow.html">QMainWindow</a> and
adding two QActions.
<p> You may use most widgets within a toolbar, with QToolButton and
<a href="qcombobox.html">QComboBox</a> being the most common.
<p> If you create a new widget on an already visible QToolBar, this
widget will automatically become visible without needing a <a href="qwidget.html#show">show</a>()
call. (This differs from every other Qt widget container. We
recommend calling show() anyway since we hope to fix this anomaly
in a future release.)
<p> QToolBars, like QDockWindows, are located in <a href="qdockarea.html">QDockArea</a>s or
float as top-level windows. QMainWindow provides four QDockAreas
(top, left, right and bottom). When you create a new toolbar (as
in the example above) as a child of a QMainWindow the toolbar will
be added to the top dock area. You can move it to another dock
area (or float it) by calling <a href="qmainwindow.html#moveDockWindow">QMainWindow::moveDockWindow</a>(). QDock
areas lay out their windows in <a href="qdockarea.html#lines">Lines</a>.
<p> If the main window is resized so that the area occupied by the
toolbar is too small to show all its widgets a little arrow button
(which looks like a right-pointing chevron, '&#187;') will appear
at the right or bottom of the toolbar depending on its
orientation. Clicking this button pops up a menu that shows the
'overflowing' items. QToolButtons are represented in the menu using
their textLabel property, other <a href="qbutton.html">QButton</a> subclasses are represented
using their text property, and QComboBoxes are represented as submenus,
with the caption text being used in the submenu item.
<p> Usually a toolbar will get precisely the space it needs. However,
with <a href="qdoctwindow.html#setHorizontalStretchable">setHorizontalStretchable</a>(), <a href="qdoctwindow.html#setVerticalStretchable">setVerticalStretchable</a>() or
<a href="#setStretchableWidget">setStretchableWidget</a>() you can tell the main window to expand the
toolbar to fill all available space in the specified orientation.
<p> The toolbar arranges its buttons either horizontally or vertically
(see <a href="qdoctwindow.html#orientation">orientation</a>() for details). Generally, <a href="qdockarea.html">QDockArea</a> will set the
orientation correctly for you, but you can set it yourself with
<a href="qdoctwindow.html#setOrientation">setOrientation</a>() and track any changes by connecting to the
<a href="qdoctwindow.html#orientationChanged">orientationChanged</a>() signal.
<p> You can use the <a href="#clear">clear</a>() method to remove all items from a toolbar.
<p> <center><img src="qdoctwindow.png" alt="Toolbar (dock window)"></center> <blockquote><p align="center"><em> A floating QToolbar (dock window)
</em></p>
</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>.

<hr><h2>Member Function Documentation</h2>
<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 )
</h3>

<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> 
<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 )
</h3>
Constructs an empty horizontal toolbar.
<p> The toolbar is called <em>name</em> and is a child of <em>parent</em> and is
managed by <em>mainWindow</em>. The <em>label</em> and <em>newLine</em> parameters
are passed straight to <a href="qmainwindow.html#addDockWindow">QMainWindow::addDockWindow</a>(). <em>name</em> and
the widget flags <em>f</em> are passed on to the <a href="qdoctwindow.html">QDockWindow</a> constructor.
<p> Use this constructor if you want to create torn-off (undocked,
floating) toolbars or toolbars in the <a href="qstatusbar.html">status
    bar</a>.

<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 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Constructs an empty toolbar called <em>name</em>, with parent <em>parent</em>,
in its <em>parent</em>'s top dock area, without any label and without
requiring a newline.

<h3 class=fn>void <a name="addSeparator"></a>QToolBar::addSeparator ()
</h3>
Adds a separator to the right/bottom of the toolbar.

<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>.
<h3 class=fn>void <a name="clear"></a>QToolBar::clear ()<tt> [virtual]</tt>
</h3>
Deletes all the toolbar's child widgets.

<h3 class=fn><a href="qstring.html">QString</a> <a name="label"></a>QToolBar::label () const
</h3><p>Returns the toolbar's label.
See the <a href="qtoolbar.html#label-prop">"label"</a> property for details.
<h3 class=fn><a href="qmainwindow.html">QMainWindow</a>&nbsp;* <a name="mainWindow"></a>QToolBar::mainWindow () const
</h3>
Returns a pointer to the <a href="qmainwindow.html">QMainWindow</a> which manages this toolbar.

<h3 class=fn>void <a name="setLabel"></a>QToolBar::setLabel ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the toolbar's label.
See the <a href="qtoolbar.html#label-prop">"label"</a> property for details.
<h3 class=fn>void <a name="setStretchableWidget"></a>QToolBar::setStretchableWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
</h3>
Sets the widget <em>w</em> to be expanded if this toolbar is requested
to stretch.
<p> The request to stretch might occur because <a href="qmainwindow.html">QMainWindow</a>
right-justifies the dock area the toolbar is in, or because this
toolbar's <a href="qdoctwindow.html#isVerticalStretchable">isVerticalStretchable</a>() or <a href="qdoctwindow.html#isHorizontalStretchable">isHorizontalStretchable</a>() is
set to TRUE.
<p> If you call this function and the toolbar is not yet stretchable,
setStretchable() is called.
<p> <p>See also <a href="qmainwindow.html#rightJustification-prop">QMainWindow::rightJustification</a>, <a href="qdoctwindow.html#setVerticalStretchable">setVerticalStretchable</a>(), and <a href="qdoctwindow.html#setHorizontalStretchable">setHorizontalStretchable</a>().

<p>Examples: <a href="fileiconview-example.html#x896">fileiconview/mainwindow.cpp</a> and <a href="helpviewer-example.html#x1034">helpviewer/helpwindow.cpp</a>.
<hr><h2>Property Documentation</h2>
<h3 class=fn><a href="qstring.html">QString</a> <a name="label-prop"></a>label</h3>
<p>This property holds the toolbar's label.
<p>If the toolbar is floated the label becomes the toolbar window's
caption. There is no default label text.

<p>Set this property's value with <a href="#setLabel">setLabel</a>() and get this property's value with <a href="#label">label</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>