Sophie

Sophie

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

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" />
<!-- qdatawidgetmapper.cpp -->
  <title>Qt 4.8: QDataWidgetMapper 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>QDataWidgetMapper</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-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QDataWidgetMapper Class Reference</h1>
<!-- $$$QDataWidgetMapper-brief -->
<p>The QDataWidgetMapper class provides mapping between a section of a data model to widgets. <a href="#details">More...</a></p>
<!-- @@@QDataWidgetMapper -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QDataWidgetMapper&gt;</span></pre><p><b>Inherits: </b><a href="qobject.html">QObject</a>.</p>
<p>This class was introduced in Qt 4.2.</p>
<ul>
<li><a href="qdatawidgetmapper-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#SubmitPolicy-enum">SubmitPolicy</a></b> { AutoSubmit, ManualSubmit }</td></tr>
</table>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a></b> : int</li>
<li class="fn"><b><a href="qdatawidgetmapper.html#orientation-prop">orientation</a></b> : Qt::Orientation</li>
<li class="fn"><b><a href="qdatawidgetmapper.html#submitPolicy-prop">submitPolicy</a></b> : SubmitPolicy</li>
</ul>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</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="qdatawidgetmapper.html#QDataWidgetMapper">QDataWidgetMapper</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#dtor.QDataWidgetMapper">~QDataWidgetMapper</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#addMapping">addMapping</a></b> ( QWidget * <i>widget</i>, int <i>section</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#addMapping-2">addMapping</a></b> ( QWidget * <i>widget</i>, int <i>section</i>, const QByteArray &amp; <i>propertyName</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#clearMapping">clearMapping</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractItemDelegate * </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#itemDelegate">itemDelegate</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#mappedPropertyName">mappedPropertyName</a></b> ( QWidget * <i>widget</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#mappedSection">mappedSection</a></b> ( QWidget * <i>widget</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget * </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#mappedWidgetAt">mappedWidgetAt</a></b> ( int <i>section</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractItemModel * </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#model">model</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::Orientation </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#orientation-prop">orientation</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#removeMapping">removeMapping</a></b> ( QWidget * <i>widget</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#rootIndex">rootIndex</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#setItemDelegate">setItemDelegate</a></b> ( QAbstractItemDelegate * <i>delegate</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#setModel">setModel</a></b> ( QAbstractItemModel * <i>model</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#orientation-prop">setOrientation</a></b> ( Qt::Orientation <i>aOrientation</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#setRootIndex">setRootIndex</a></b> ( const QModelIndex &amp; <i>index</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#submitPolicy-prop">setSubmitPolicy</a></b> ( SubmitPolicy <i>policy</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> SubmitPolicy </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#submitPolicy-prop">submitPolicy</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2>Public Slots</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#revert">revert</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a></b> ( int <i>index</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#setCurrentModelIndex">setCurrentModelIndex</a></b> ( const QModelIndex &amp; <i>index</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#submit">submit</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#toFirst">toFirst</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#toLast">toLast</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#toNext">toNext</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#toPrevious">toPrevious</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdatawidgetmapper.html#currentIndexChanged">currentIndexChanged</a></b> ( int <i>index</i> )</td></tr>
</table>
<ul>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QDataWidgetMapper-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QDataWidgetMapper class provides mapping between a section of a data model to widgets.</p>
<p>QDataWidgetMapper can be used to create data-aware widgets by mapping them to sections of an item model. A section is a column of a model if the orientation is horizontal (the default), otherwise a row.</p>
<p>Every time the current index changes, each widget is updated with data from the model via the property specified when its mapping was made. If the user edits the contents of a widget, the changes are read using the same property and written back to the model. By default, each widget's <a href="qobject.html#Q_PROPERTY">user property</a> is used to transfer data between the model and the widget. Since Qt 4.3, an additional <a href="qdatawidgetmapper.html#addMapping">addMapping</a>() function enables a named property to be used instead of the default user property.</p>
<p>It is possible to set an item delegate to support custom widgets. By default, a <a href="qitemdelegate.html">QItemDelegate</a> is used to synchronize the model with the widgets.</p>
<p>Let us assume that we have an item model named <tt>model</tt> with the following contents:</p>
<table class="generic">
<tr valign="top" class="odd"><td >1</td><td >Qt Norway</td><td >Oslo</td></tr>
<tr valign="top" class="even"><td >2</td><td >Qt Australia</td><td >Brisbane</td></tr>
<tr valign="top" class="odd"><td >3</td><td >Qt USA</td><td >Palo Alto</td></tr>
<tr valign="top" class="even"><td >4</td><td >Qt China</td><td >Beijing</td></tr>
<tr valign="top" class="odd"><td >5</td><td >Qt Germany</td><td >Berlin</td></tr>
</table>
<p>The following code will map the columns of the model to widgets called <tt>mySpinBox</tt>, <tt>myLineEdit</tt> and <tt>myCountryChooser</tt>:</p>
<pre class="cpp"> <span class="type">QDataWidgetMapper</span> <span class="operator">*</span>mapper <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QDataWidgetMapper</span>;
 mapper<span class="operator">-</span><span class="operator">&gt;</span><a href="qdatawidgetmapper.html#setModel">setModel</a>(model);
 mapper<span class="operator">-</span><span class="operator">&gt;</span><a href="qdatawidgetmapper.html#addMapping">addMapping</a>(mySpinBox<span class="operator">,</span> <span class="number">0</span>);
 mapper<span class="operator">-</span><span class="operator">&gt;</span><a href="qdatawidgetmapper.html#addMapping">addMapping</a>(myLineEdit<span class="operator">,</span> <span class="number">1</span>);
 mapper<span class="operator">-</span><span class="operator">&gt;</span><a href="qdatawidgetmapper.html#addMapping">addMapping</a>(myCountryChooser<span class="operator">,</span> <span class="number">2</span>);
 mapper<span class="operator">-</span><span class="operator">&gt;</span><a href="qdatawidgetmapper.html#toFirst">toFirst</a>();</pre>
<p>After the call to <a href="qdatawidgetmapper.html#toFirst">toFirst</a>(), <tt>mySpinBox</tt> displays the value <tt>1</tt>, <tt>myLineEdit</tt> displays <tt>Qt Norway</tt> and <tt>myCountryChooser</tt> displays <tt>Oslo</tt>. The navigational functions <a href="qdatawidgetmapper.html#toFirst">toFirst</a>(), <a href="qdatawidgetmapper.html#toNext">toNext</a>(), <a href="qdatawidgetmapper.html#toPrevious">toPrevious</a>(), <a href="qdatawidgetmapper.html#toLast">toLast</a>() and <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>() can be used to navigate in the model and update the widgets with contents from the model.</p>
<p>The <a href="qdatawidgetmapper.html#setRootIndex">setRootIndex</a>() function enables a particular item in a model to be specified as the root index - children of this item will be mapped to the relevant widgets in the user interface.</p>
<p>QDataWidgetMapper supports two submit policies, <tt>AutoSubmit</tt> and <tt>ManualSubmit</tt>. <tt>AutoSubmit</tt> will update the model as soon as the current widget loses focus, <tt>ManualSubmit</tt> will not update the model unless <a href="qdatawidgetmapper.html#submit">submit</a>() is called. <tt>ManualSubmit</tt> is useful when displaying a dialog that lets the user cancel all modifications. Also, other views that display the model won't update until the user finishes all their modifications and submits.</p>
<p>Note that QDataWidgetMapper keeps track of external modifications. If the contents of the model are updated in another module of the application, the widgets are updated as well.</p>
</div>
<p><b>See also </b><a href="qabstractitemmodel.html">QAbstractItemModel</a> and <a href="qabstractitemdelegate.html">QAbstractItemDelegate</a>.</p>
<!-- @@@QDataWidgetMapper -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$SubmitPolicy$$$AutoSubmit$$$ManualSubmit -->
<h3 class="fn"><a name="SubmitPolicy-enum"></a>enum QDataWidgetMapper::<span class="name">SubmitPolicy</span></h3>
<p>This enum describes the possible submit policies a <a href="qdatawidgetmapper.html">QDataWidgetMapper</a> supports.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QDataWidgetMapper::AutoSubmit</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">Whenever a widget loses focus, the widget's current value is set to the item model.</td></tr>
<tr><td class="topAlign"><tt>QDataWidgetMapper::ManualSubmit</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The model is not updated until <a href="qdatawidgetmapper.html#submit">submit</a>() is called.</td></tr>
</table>
<!-- @@@SubmitPolicy -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$currentIndex-prop$$$currentIndex$$$setCurrentIndexint$$$currentIndexChangedint -->
<h3 class="fn"><a name="currentIndex-prop"></a><span class="name">currentIndex</span> : <span class="type">int</span></h3>
<p>This property holds the current row or column.</p>
<p>The widgets are populated with with data from the row at <i>index</i> if the orientation is horizontal (the default), otherwise with data from the column at <i>index</i>.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>currentIndex</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> virtual void </td><td class="memItemRight bottomAlign"><span class="name"><b>setCurrentIndex</b></span> ( int <i>index</i> )</td></tr>
</table>
<p><b>Notifier signal:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qdatawidgetmapper.html#currentIndexChanged">currentIndexChanged</a></b></span> ( int <i>index</i> )</td></tr>
</table>
<p><b>See also </b><a href="qdatawidgetmapper.html#setCurrentModelIndex">setCurrentModelIndex</a>(), <a href="qdatawidgetmapper.html#toFirst">toFirst</a>(), <a href="qdatawidgetmapper.html#toNext">toNext</a>(), <a href="qdatawidgetmapper.html#toPrevious">toPrevious</a>(), and <a href="qdatawidgetmapper.html#toLast">toLast</a>().</p>
<!-- @@@currentIndex -->
<!-- $$$orientation-prop$$$orientation$$$setOrientationQt::Orientation -->
<h3 class="fn"><a name="orientation-prop"></a><span class="name">orientation</span> : <span class="type"><a href="qt.html#Orientation-enum">Qt::Orientation</a></span></h3>
<p>This property holds the orientation of the model.</p>
<p>If the orientation is <a href="qt.html#Orientation-enum">Qt::Horizontal</a> (the default), a widget is mapped to a column of a data model. The widget will be populated with the model's data from its mapped column and the row that <a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a>() points at.</p>
<p>Use <a href="qt.html#Orientation-enum">Qt::Horizontal</a> for tabular data that looks like this:</p>
<table class="generic">
<tr valign="top" class="odd"><td >1</td><td >Qt Norway</td><td >Oslo</td></tr>
<tr valign="top" class="even"><td >2</td><td >Qt Australia</td><td >Brisbane</td></tr>
<tr valign="top" class="odd"><td >3</td><td >Qt USA</td><td >Silicon Valley</td></tr>
<tr valign="top" class="even"><td >4</td><td >Qt China</td><td >Beijing</td></tr>
<tr valign="top" class="odd"><td >5</td><td >Qt Germany</td><td >Berlin</td></tr>
</table>
<p>If the orientation is set to <a href="qt.html#Orientation-enum">Qt::Vertical</a>, a widget is mapped to a row. Calling <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>() will change the current column. The widget will be populates with the model's data from its mapped row and the column that <a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a>() points at.</p>
<p>Use <a href="qt.html#Orientation-enum">Qt::Vertical</a> for tabular data that looks like this:</p>
<table class="generic">
<tr valign="top" class="odd"><td >1</td><td >2</td><td >3</td><td >4</td><td >5</td></tr>
<tr valign="top" class="even"><td >Qt Norway</td><td >Qt Australia</td><td >Qt USA</td><td >Qt China</td><td >Qt Germany</td></tr>
<tr valign="top" class="odd"><td >Oslo</td><td >Brisbane</td><td >Silicon Valley</td><td >Beijing</td><td >Berlin</td></tr>
</table>
<p>Changing the orientation clears all existing mappings.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::Orientation </td><td class="memItemRight bottomAlign"><span class="name"><b>orientation</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOrientation</b></span> ( Qt::Orientation <i>aOrientation</i> )</td></tr>
</table>
<!-- @@@orientation -->
<!-- $$$submitPolicy-prop$$$submitPolicy$$$setSubmitPolicySubmitPolicy -->
<h3 class="fn"><a name="submitPolicy-prop"></a><span class="name">submitPolicy</span> : <span class="type"><a href="qdatawidgetmapper.html#SubmitPolicy-enum">SubmitPolicy</a></span></h3>
<p>This property holds the current submit policy.</p>
<p>Changing the current submit policy will revert all widgets to the current data from the model.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> SubmitPolicy </td><td class="memItemRight bottomAlign"><span class="name"><b>submitPolicy</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setSubmitPolicy</b></span> ( SubmitPolicy <i>policy</i> )</td></tr>
</table>
<!-- @@@submitPolicy -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QDataWidgetMapper[overload1]$$$QDataWidgetMapperQObject* -->
<h3 class="fn"><a name="QDataWidgetMapper"></a>QDataWidgetMapper::<span class="name">QDataWidgetMapper</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a new <a href="qdatawidgetmapper.html">QDataWidgetMapper</a> with parent object <i>parent</i>. By default, the orientation is horizontal and the submit policy is <tt>AutoSubmit</tt>.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#orientation-prop">setOrientation</a>() and <a href="qdatawidgetmapper.html#submitPolicy-prop">setSubmitPolicy</a>().</p>
<!-- @@@QDataWidgetMapper -->
<!-- $$$~QDataWidgetMapper[overload1]$$$~QDataWidgetMapper -->
<h3 class="fn"><a name="dtor.QDataWidgetMapper"></a>QDataWidgetMapper::<span class="name">~QDataWidgetMapper</span> ()</h3>
<p>Destroys the object.</p>
<!-- @@@~QDataWidgetMapper -->
<!-- $$$addMapping[overload1]$$$addMappingQWidget*int -->
<h3 class="fn"><a name="addMapping"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">addMapping</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i>, <span class="type">int</span> <i>section</i> )</h3>
<p>Adds a mapping between a <i>widget</i> and a <i>section</i> from the model. The <i>section</i> is a column in the model if the orientation is horizontal (the default), otherwise a row.</p>
<p>For the following example, we assume a model <tt>myModel</tt> that has two columns: the first one contains the names of people in a group, and the second column contains their ages. The first column is mapped to the <a href="qlineedit.html">QLineEdit</a> <tt>nameLineEdit</tt>, and the second is mapped to the <a href="qspinbox.html">QSpinBox</a> <tt>ageSpinBox</tt>:</p>
<pre class="cpp"> <span class="type"><a href="qdatawidgetmapper.html">QDataWidgetMapper</a></span> <span class="operator">*</span>mapper <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdatawidgetmapper.html">QDataWidgetMapper</a></span>();
 mapper<span class="operator">-</span><span class="operator">&gt;</span><a href="qdatawidgetmapper.html#setModel">setModel</a>(myModel);
 mapper<span class="operator">-</span><span class="operator">&gt;</span>addMapping(nameLineEdit<span class="operator">,</span> <span class="number">0</span>);
 mapper<span class="operator">-</span><span class="operator">&gt;</span>addMapping(ageSpinBox<span class="operator">,</span> <span class="number">1</span>);</pre>
<p><b>Notes:</b></p>
<ul>
<li>If the <i>widget</i> is already mapped to a section, the old mapping will be replaced by the new one.</li>
<li>Only one-to-one mappings between sections and widgets are allowed. It is not possible to map a single section to multiple widgets, or to map a single widget to multiple sections.</li>
</ul>
<p><b>See also </b><a href="qdatawidgetmapper.html#removeMapping">removeMapping</a>(), <a href="qdatawidgetmapper.html#mappedSection">mappedSection</a>(), and <a href="qdatawidgetmapper.html#clearMapping">clearMapping</a>().</p>
<!-- @@@addMapping -->
<!-- $$$addMapping$$$addMappingQWidget*intconstQByteArray& -->
<h3 class="fn"><a name="addMapping-2"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">addMapping</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i>, <span class="type">int</span> <i>section</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp; <i>propertyName</i> )</h3>
<p>Essentially the same as <a href="qdatawidgetmapper.html#addMapping">addMapping</a>(), but adds the possibility to specify the property to use specifying <i>propertyName</i>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#addMapping">addMapping</a>().</p>
<!-- @@@addMapping -->
<!-- $$$clearMapping[overload1]$$$clearMapping -->
<h3 class="fn"><a name="clearMapping"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">clearMapping</span> ()</h3>
<p>Clears all mappings.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#addMapping">addMapping</a>() and <a href="qdatawidgetmapper.html#removeMapping">removeMapping</a>().</p>
<!-- @@@clearMapping -->
<!-- $$$currentIndexChanged[overload1]$$$currentIndexChangedint -->
<h3 class="fn"><a name="currentIndexChanged"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">currentIndexChanged</span> ( <span class="type">int</span> <i>index</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted after the current index has changed and all widgets were populated with new data. <i>index</i> is the new current index.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a>() and <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>().</p>
<!-- @@@currentIndexChanged -->
<!-- $$$itemDelegate[overload1]$$$itemDelegate -->
<h3 class="fn"><a name="itemDelegate"></a><span class="type"><a href="qabstractitemdelegate.html">QAbstractItemDelegate</a></span> * QDataWidgetMapper::<span class="name">itemDelegate</span> () const</h3>
<p>Returns the current item delegate.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#setItemDelegate">setItemDelegate</a>().</p>
<!-- @@@itemDelegate -->
<!-- $$$mappedPropertyName[overload1]$$$mappedPropertyNameQWidget* -->
<h3 class="fn"><a name="mappedPropertyName"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QDataWidgetMapper::<span class="name">mappedPropertyName</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> ) const</h3>
<p>Returns the name of the property that is used when mapping data to the given <i>widget</i>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#mappedSection">mappedSection</a>(), <a href="qdatawidgetmapper.html#addMapping">addMapping</a>(), and <a href="qdatawidgetmapper.html#removeMapping">removeMapping</a>().</p>
<!-- @@@mappedPropertyName -->
<!-- $$$mappedSection[overload1]$$$mappedSectionQWidget* -->
<h3 class="fn"><a name="mappedSection"></a><span class="type">int</span> QDataWidgetMapper::<span class="name">mappedSection</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> ) const</h3>
<p>Returns the section the <i>widget</i> is mapped to or -1 if the widget is not mapped.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#addMapping">addMapping</a>() and <a href="qdatawidgetmapper.html#removeMapping">removeMapping</a>().</p>
<!-- @@@mappedSection -->
<!-- $$$mappedWidgetAt[overload1]$$$mappedWidgetAtint -->
<h3 class="fn"><a name="mappedWidgetAt"></a><span class="type"><a href="qwidget.html">QWidget</a></span> * QDataWidgetMapper::<span class="name">mappedWidgetAt</span> ( <span class="type">int</span> <i>section</i> ) const</h3>
<p>Returns the widget that is mapped at <i>section</i>, or 0 if no widget is mapped at that section.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#addMapping">addMapping</a>() and <a href="qdatawidgetmapper.html#removeMapping">removeMapping</a>().</p>
<!-- @@@mappedWidgetAt -->
<!-- $$$model[overload1]$$$model -->
<h3 class="fn"><a name="model"></a><span class="type"><a href="qabstractitemmodel.html">QAbstractItemModel</a></span> * QDataWidgetMapper::<span class="name">model</span> () const</h3>
<p>Returns the current model.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#setModel">setModel</a>().</p>
<!-- @@@model -->
<!-- $$$removeMapping[overload1]$$$removeMappingQWidget* -->
<h3 class="fn"><a name="removeMapping"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">removeMapping</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> )</h3>
<p>Removes the mapping for the given <i>widget</i>.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#addMapping">addMapping</a>() and <a href="qdatawidgetmapper.html#clearMapping">clearMapping</a>().</p>
<!-- @@@removeMapping -->
<!-- $$$revert[overload1]$$$revert -->
<h3 class="fn"><a name="revert"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">revert</span> ()<tt> [slot]</tt></h3>
<p>Repopulates all widgets with the current data of the model. All unsubmitted changes will be lost.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#submit">submit</a>() and <a href="qdatawidgetmapper.html#submitPolicy-prop">setSubmitPolicy</a>().</p>
<!-- @@@revert -->
<!-- $$$rootIndex[overload1]$$$rootIndex -->
<h3 class="fn"><a name="rootIndex"></a><span class="type"><a href="qmodelindex.html">QModelIndex</a></span> QDataWidgetMapper::<span class="name">rootIndex</span> () const</h3>
<p>Returns the current root index.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#setRootIndex">setRootIndex</a>().</p>
<!-- @@@rootIndex -->
<!-- $$$setCurrentModelIndex[overload1]$$$setCurrentModelIndexconstQModelIndex& -->
<h3 class="fn"><a name="setCurrentModelIndex"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">setCurrentModelIndex</span> ( const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> )<tt> [slot]</tt></h3>
<p>Sets the current index to the row of the <i>index</i> if the orientation is horizontal (the default), otherwise to the column of the <i>index</i>.</p>
<p>Calls <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>() internally. This convenience slot can be connected to the signal <a href="qitemselectionmodel.html#currentRowChanged">currentRowChanged()</a> or <a href="qitemselectionmodel.html#currentColumnChanged">currentColumnChanged()</a> of another view's <a href="qitemselectionmodel.html">selection model</a>.</p>
<p>The following example illustrates how to update all widgets with new data whenever the selection of a <a href="qtableview.html">QTableView</a> named <tt>myTableView</tt> changes:</p>
<pre class="cpp"> <span class="type"><a href="qdatawidgetmapper.html">QDataWidgetMapper</a></span> <span class="operator">*</span>mapper <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdatawidgetmapper.html">QDataWidgetMapper</a></span>();
 <a href="qobject.html#connect">connect</a>(myTableView<span class="operator">-</span><span class="operator">&gt;</span>selectionModel()<span class="operator">,</span> SIGNAL(currentRowChanged(<span class="type"><a href="qmodelindex.html">QModelIndex</a></span><span class="operator">,</span><span class="type"><a href="qmodelindex.html">QModelIndex</a></span>))<span class="operator">,</span>
         mapper<span class="operator">,</span> SLOT(setCurrentModelIndex(<span class="type"><a href="qmodelindex.html">QModelIndex</a></span>)));</pre>
<p><b>See also </b><a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a>().</p>
<!-- @@@setCurrentModelIndex -->
<!-- $$$setItemDelegate[overload1]$$$setItemDelegateQAbstractItemDelegate* -->
<h3 class="fn"><a name="setItemDelegate"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">setItemDelegate</span> ( <span class="type"><a href="qabstractitemdelegate.html">QAbstractItemDelegate</a></span> * <i>delegate</i> )</h3>
<p>Sets the item delegate to <i>delegate</i>. The delegate will be used to write data from the model into the widget and from the widget to the model, using <a href="qabstractitemdelegate.html#setEditorData">QAbstractItemDelegate::setEditorData</a>() and <a href="qabstractitemdelegate.html#setModelData">QAbstractItemDelegate::setModelData</a>().</p>
<p>The delegate also decides when to apply data and when to change the editor, using <a href="qabstractitemdelegate.html#commitData">QAbstractItemDelegate::commitData</a>() and <a href="qabstractitemdelegate.html#closeEditor">QAbstractItemDelegate::closeEditor</a>().</p>
<p><b>Warning:</b> You should not share the same instance of a delegate between widget mappers or views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the <a href="qabstractitemdelegate.html#closeEditor">closeEditor()</a> signal, and attempt to access, modify or close an editor that has already been closed.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#itemDelegate">itemDelegate</a>().</p>
<!-- @@@setItemDelegate -->
<!-- $$$setModel[overload1]$$$setModelQAbstractItemModel* -->
<h3 class="fn"><a name="setModel"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">setModel</span> ( <span class="type"><a href="qabstractitemmodel.html">QAbstractItemModel</a></span> * <i>model</i> )</h3>
<p>Sets the current model to <i>model</i>. If another model was set, all mappings to that old model are cleared.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#model">model</a>().</p>
<!-- @@@setModel -->
<!-- $$$setRootIndex[overload1]$$$setRootIndexconstQModelIndex& -->
<h3 class="fn"><a name="setRootIndex"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">setRootIndex</span> ( const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> )</h3>
<p>Sets the root item to <i>index</i>. This can be used to display a branch of a tree. Pass an invalid model index to display the top-most branch.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#rootIndex">rootIndex</a>().</p>
<!-- @@@setRootIndex -->
<!-- $$$submit[overload1]$$$submit -->
<h3 class="fn"><a name="submit"></a><span class="type">bool</span> QDataWidgetMapper::<span class="name">submit</span> ()<tt> [slot]</tt></h3>
<p>Submits all changes from the mapped widgets to the model.</p>
<p>For every mapped section, the item delegate reads the current value from the widget and sets it in the model. Finally, the model's <a href="qabstractitemmodel.html#submit">submit()</a> method is invoked.</p>
<p>Returns true if all the values were submitted, otherwise false.</p>
<p>Note: For database models, <a href="qsqlquerymodel.html#lastError">QSqlQueryModel::lastError</a>() can be used to retrieve the last error.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#revert">revert</a>() and <a href="qdatawidgetmapper.html#submitPolicy-prop">setSubmitPolicy</a>().</p>
<!-- @@@submit -->
<!-- $$$toFirst[overload1]$$$toFirst -->
<h3 class="fn"><a name="toFirst"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">toFirst</span> ()<tt> [slot]</tt></h3>
<p>Populates the widgets with data from the first row of the model if the orientation is horizontal (the default), otherwise with data from the first column.</p>
<p>This is equivalent to calling <tt>setCurrentIndex(0)</tt>.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#toLast">toLast</a>() and <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>().</p>
<!-- @@@toFirst -->
<!-- $$$toLast[overload1]$$$toLast -->
<h3 class="fn"><a name="toLast"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">toLast</span> ()<tt> [slot]</tt></h3>
<p>Populates the widgets with data from the last row of the model if the orientation is horizontal (the default), otherwise with data from the last column.</p>
<p>Calls <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>() internally.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#toFirst">toFirst</a>() and <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>().</p>
<!-- @@@toLast -->
<!-- $$$toNext[overload1]$$$toNext -->
<h3 class="fn"><a name="toNext"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">toNext</span> ()<tt> [slot]</tt></h3>
<p>Populates the widgets with data from the next row of the model if the orientation is horizontal (the default), otherwise with data from the next column.</p>
<p>Calls <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>() internally. Does nothing if there is no next row in the model.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#toPrevious">toPrevious</a>() and <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>().</p>
<!-- @@@toNext -->
<!-- $$$toPrevious[overload1]$$$toPrevious -->
<h3 class="fn"><a name="toPrevious"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">toPrevious</span> ()<tt> [slot]</tt></h3>
<p>Populates the widgets with data from the previous row of the model if the orientation is horizontal (the default), otherwise with data from the previous column.</p>
<p>Calls <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>() internally. Does nothing if there is no previous row in the model.</p>
<p><b>See also </b><a href="qdatawidgetmapper.html#toNext">toNext</a>() and <a href="qdatawidgetmapper.html#currentIndex-prop">setCurrentIndex</a>().</p>
<!-- @@@toPrevious -->
</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>