Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > ff187cb994c94c614ecc64c5a8528b1b > files > 7060

qt-doc-4.8.5-10.fc18.noarch.rpm

<?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/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <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 class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></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>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc 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>
      Digia, Qt and their respective logos are trademarks of Digia Plc 
      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>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>