File: qwidgetaction.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (184 lines) | stat: -rw-r--r-- 15,982 bytes parent folder | download
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qwidgetaction.cpp -->
  <title>Qt 4.8: QWidgetAction Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QWidgetAction</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QWidgetAction Class Reference</h1>
<!-- $$$QWidgetAction-brief -->
<p>The QWidgetAction class extends <a href="qaction.html">QAction</a> by an interface for inserting custom widgets into action based containers, such as toolbars. <a href="#details">More...</a></p>
<!-- @@@QWidgetAction -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QWidgetAction&gt;</span></pre><p><b>Inherits: </b><a href="qaction.html">QAction</a>.</p>
<p>This class was introduced in Qt 4.2.</p>
<ul>
<li><a href="qwidgetaction-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#QWidgetAction">QWidgetAction</a></b> ( QObject * <i>parent</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#dtor.QWidgetAction">~QWidgetAction</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget * </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#defaultWidget">defaultWidget</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#releaseWidget">releaseWidget</a></b> ( QWidget * <i>widget</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget * </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#requestWidget">requestWidget</a></b> ( QWidget * <i>parent</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#setDefaultWidget">setDefaultWidget</a></b> ( QWidget * <i>widget</i> )</td></tr>
</table>
<ul>
<li class="fn">49 public functions inherited from <a href="qaction.html#public-functions">QAction</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QWidget * </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#createWidget">createWidget</a></b> ( QWidget * <i>parent</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QWidget *&gt; </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#createdWidgets">createdWidgets</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#deleteWidget">deleteWidget</a></b> ( QWidget * <i>widget</i> )</td></tr>
</table>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#event">event</a></b> ( QEvent * <i>event</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qwidgetaction.html#eventFilter">eventFilter</a></b> ( QObject * <i>obj</i>, QEvent * <i>event</i> )</td></tr>
</table>
<ul>
<li class="fn">1 protected function inherited from <a href="qaction.html#protected-functions">QAction</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">18 properties inherited from <a href="qaction.html#properties">QAction</a></li>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li class="fn">7 public slots inherited from <a href="qaction.html#public-slots">QAction</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">4 signals inherited from <a href="qaction.html#signals">QAction</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QWidgetAction-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QWidgetAction class extends <a href="qaction.html">QAction</a> by an interface for inserting custom widgets into action based containers, such as toolbars.</p>
<p>Most actions in an application are represented as items in menus or buttons in toolbars. However sometimes more complex widgets are necessary. For example a zoom action in a word processor may be realized using a <a href="qcombobox.html">QComboBox</a> in a <a href="qtoolbar.html">QToolBar</a>, presenting a range of different zoom levels. <a href="qtoolbar.html">QToolBar</a> provides <a href="qtoolbar.html#insertWidget">QToolBar::insertWidget</a>() as convenience function for inserting a single widget. However if you want to implement an action that uses custom widgets for visualization in multiple containers then you have to subclass QWidgetAction.</p>
<p>If a QWidgetAction is added for example to a <a href="qtoolbar.html">QToolBar</a> then <a href="qwidgetaction.html#createWidget">QWidgetAction::createWidget</a>() is called. Reimplementations of that function should create a new custom widget with the specified parent.</p>
<p>If the action is removed from a container widget then <a href="qwidgetaction.html#deleteWidget">QWidgetAction::deleteWidget</a>() is called with the previously created custom widget as argument. The default implementation hides the widget and deletes it using <a href="qobject.html#deleteLater">QObject::deleteLater</a>().</p>
<p>If you have only one single custom widget then you can set it as default widget using <a href="qwidgetaction.html#setDefaultWidget">setDefaultWidget</a>(). That widget will then be used if the action is added to a <a href="qtoolbar.html">QToolBar</a>, or in general to an action container that supports QWidgetAction. If a QWidgetAction with only a default widget is added to two toolbars at the same time then the default widget is shown only in the first toolbar the action was added to. QWidgetAction takes over ownership of the default widget.</p>
<p>Note that it is up to the widget to activate the action, for example by reimplementing mouse event handlers and calling <a href="qaction.html#trigger">QAction::trigger</a>().</p>
<p><b>Mac OS X</b>: If you add a widget to a menu in the application's menu bar on Mac OS X, the widget will be added and it will function but with some limitations:</p>
<ol class="1">
<li>The widget is reparented away from the <a href="qmenu.html">QMenu</a> to the native menu view. If you show the menu in some other place (e.g&#x2e; as a popup menu), the widget will not be there.</li>
<li>Focus/Keyboard handling of the widget is not possible.</li>
<li>Due to Apple's design, mouse tracking on the widget currently does not work.</li>
<li>Connecting the <a href="qaction.html#triggered">triggered</a>() signal to a slot that opens a modal dialog will cause a crash in Mac OS X 10.4 (known bug acknowledged by Apple), a workaround is to use a QueuedConnection instead of a DirectConnection.</li>
</ol>
</div>
<p><b>See also </b><a href="qaction.html">QAction</a>, <a href="qactiongroup.html">QActionGroup</a>, and <a href="qwidget.html">QWidget</a>.</p>
<!-- @@@QWidgetAction -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QWidgetAction[overload1]$$$QWidgetActionQObject* -->
<h3 class="fn"><a name="QWidgetAction"></a>QWidgetAction::<span class="name">QWidgetAction</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> )</h3>
<p>Constructs an action with <i>parent</i>.</p>
<!-- @@@QWidgetAction -->
<!-- $$$~QWidgetAction[overload1]$$$~QWidgetAction -->
<h3 class="fn"><a name="dtor.QWidgetAction"></a>QWidgetAction::<span class="name">~QWidgetAction</span> ()<tt> [virtual]</tt></h3>
<p>Destroys the object and frees allocated resources.</p>
<!-- @@@~QWidgetAction -->
<!-- $$$createWidget[overload1]$$$createWidgetQWidget* -->
<h3 class="fn"><a name="createWidget"></a><span class="type"><a href="qwidget.html">QWidget</a></span> * QWidgetAction::<span class="name">createWidget</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> )<tt> [virtual protected]</tt></h3>
<p>This function is called whenever the action is added to a container widget that supports custom widgets. If you don't want a custom widget to be used as representation of the action in the specified <i>parent</i> widget then 0 should be returned.</p>
<p><b>See also </b><a href="qwidgetaction.html#deleteWidget">deleteWidget</a>().</p>
<!-- @@@createWidget -->
<!-- $$$createdWidgets[overload1]$$$createdWidgets -->
<h3 class="fn"><a name="createdWidgets"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qwidget.html">QWidget</a></span> *&gt; QWidgetAction::<span class="name">createdWidgets</span> () const<tt> [protected]</tt></h3>
<p>Returns the list of widgets that have been using <a href="qwidgetaction.html#createWidget">createWidget</a>() and are currently in use by widgets the action has been added to.</p>
<!-- @@@createdWidgets -->
<!-- $$$defaultWidget[overload1]$$$defaultWidget -->
<h3 class="fn"><a name="defaultWidget"></a><span class="type"><a href="qwidget.html">QWidget</a></span> * QWidgetAction::<span class="name">defaultWidget</span> () const</h3>
<p>Returns the default widget.</p>
<p><b>See also </b><a href="qwidgetaction.html#setDefaultWidget">setDefaultWidget</a>().</p>
<!-- @@@defaultWidget -->
<!-- $$$deleteWidget[overload1]$$$deleteWidgetQWidget* -->
<h3 class="fn"><a name="deleteWidget"></a><span class="type">void</span> QWidgetAction::<span class="name">deleteWidget</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> )<tt> [virtual protected]</tt></h3>
<p>This function is called whenever the action is removed from a container widget that displays the action using a custom <i>widget</i> previously created using <a href="qwidgetaction.html#createWidget">createWidget</a>(). The default implementation hides the <i>widget</i> and schedules it for deletion using <a href="qobject.html#deleteLater">QObject::deleteLater</a>().</p>
<p><b>See also </b><a href="qwidgetaction.html#createWidget">createWidget</a>().</p>
<!-- @@@deleteWidget -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn"><a name="event"></a><span class="type">bool</span> QWidgetAction::<span class="name">event</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$eventFilter[overload1]$$$eventFilterQObject*QEvent* -->
<h3 class="fn"><a name="eventFilter"></a><span class="type">bool</span> QWidgetAction::<span class="name">eventFilter</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>obj</i>, <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#eventFilter">QObject::eventFilter</a>().</p>
<!-- @@@eventFilter -->
<!-- $$$releaseWidget[overload1]$$$releaseWidgetQWidget* -->
<h3 class="fn"><a name="releaseWidget"></a><span class="type">void</span> QWidgetAction::<span class="name">releaseWidget</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> )</h3>
<p>Releases the specified <i>widget</i>.</p>
<p>Container widgets that support actions call this function when a widget action is removed.</p>
<p><b>See also </b><a href="qwidgetaction.html#requestWidget">requestWidget</a>(), <a href="qwidgetaction.html#deleteWidget">deleteWidget</a>(), and <a href="qwidgetaction.html#defaultWidget">defaultWidget</a>().</p>
<!-- @@@releaseWidget -->
<!-- $$$requestWidget[overload1]$$$requestWidgetQWidget* -->
<h3 class="fn"><a name="requestWidget"></a><span class="type"><a href="qwidget.html">QWidget</a></span> * QWidgetAction::<span class="name">requestWidget</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> )</h3>
<p>Returns a widget that represents the action, with the given <i>parent</i>.</p>
<p>Container widgets that support actions can call this function to request a widget as visual representation of the action.</p>
<p><b>See also </b><a href="qwidgetaction.html#releaseWidget">releaseWidget</a>(), <a href="qwidgetaction.html#createWidget">createWidget</a>(), and <a href="qwidgetaction.html#defaultWidget">defaultWidget</a>().</p>
<!-- @@@requestWidget -->
<!-- $$$setDefaultWidget[overload1]$$$setDefaultWidgetQWidget* -->
<h3 class="fn"><a name="setDefaultWidget"></a><span class="type">void</span> QWidgetAction::<span class="name">setDefaultWidget</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> )</h3>
<p>Sets <i>widget</i> to be the default widget. The ownership is transferred to <a href="qwidgetaction.html">QWidgetAction</a>. Unless <a href="qwidgetaction.html#createWidget">createWidget</a>() is reimplemented by a subclass to return a new widget the default widget is used when a container widget requests a widget through <a href="qwidgetaction.html#requestWidget">requestWidget</a>().</p>
<p><b>See also </b><a href="qwidgetaction.html#defaultWidget">defaultWidget</a>().</p>
<!-- @@@setDefaultWidget -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>