Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 3254

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdatawidgetmapper.cpp -->
  <title>QDataWidgetMapper Class | Qt Widgets 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QDataWidgetMapper</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<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>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QDataWidgetMapper Class</h1>
<!-- $$$QDataWidgetMapper-brief -->
<p>The <a href="qdatawidgetmapper.html">QDataWidgetMapper</a> class provides mapping between a section of a data model to widgets. <a href="#details">More...</a></p>
<!-- @@@QDataWidgetMapper -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QDataWidgetMapper&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qobject.html">QObject</a></td></tr></table></div><ul>
<li><a href="qdatawidgetmapper-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><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></div>
<a name="properties"></a>
<h2 id="properties">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="../qtcore/qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><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> = Q_NULLPTR)</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-1">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></div>
<ul>
<li class="fn">32 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><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></div>
<ul>
<li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><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></div>
<ul>
<li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li>
<li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
<li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QDataWidgetMapper-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qdatawidgetmapper.html">QDataWidgetMapper</a> class provides mapping between a section of a data model to widgets.</p>
<p><a href="qdatawidgetmapper.html">QDataWidgetMapper</a> 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="../qtcore/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 <code>model</code> with the following contents:</p>
<div class="table"><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></div>
<p>The following code will map the columns of the model to widgets called <code>mySpinBox</code>, <code>myLineEdit</code> and <code>myCountryChooser</code>:</p>
<pre class="cpp">

  <span class="type"><a href="qdatawidgetmapper.html#QDataWidgetMapper">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">QDataWidgetMapper</a></span>;
  mapper<span class="operator">-</span><span class="operator">&gt;</span>setModel(model);
  mapper<span class="operator">-</span><span class="operator">&gt;</span>addMapping(mySpinBox<span class="operator">,</span> <span class="number">0</span>);
  mapper<span class="operator">-</span><span class="operator">&gt;</span>addMapping(myLineEdit<span class="operator">,</span> <span class="number">1</span>);
  mapper<span class="operator">-</span><span class="operator">&gt;</span>addMapping(myCountryChooser<span class="operator">,</span> <span class="number">2</span>);
  mapper<span class="operator">-</span><span class="operator">&gt;</span>toFirst();

</pre>
<p>After the call to <a href="qdatawidgetmapper.html#toFirst">toFirst</a>(), <code>mySpinBox</code> displays the value <code>1</code>, <code>myLineEdit</code> displays <code>Qt Norway</code> and <code>myCountryChooser</code> displays <code>Oslo</code>. 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><a href="qdatawidgetmapper.html">QDataWidgetMapper</a> supports two submit policies, <code>AutoSubmit</code> and <code>ManualSubmit</code>. <code>AutoSubmit</code> will update the model as soon as the current widget loses focus, <code>ManualSubmit</code> will not update the model unless <a href="qdatawidgetmapper.html#submit">submit</a>() is called. <code>ManualSubmit</code> 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 <a href="qdatawidgetmapper.html">QDataWidgetMapper</a> 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="../qtcore/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" id="SubmitPolicy-enum"><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>
<div class="table"><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"><code>QDataWidgetMapper::AutoSubmit</code></td><td class="topAlign tblval"><code>0</code></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"><code>QDataWidgetMapper::ManualSubmit</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The model is not updated until <a href="qdatawidgetmapper.html#submit">submit</a>() is called.</td></tr>
</table></div>
<!-- @@@SubmitPolicy -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$currentIndex-prop$$$currentIndex$$$setCurrentIndexint$$$currentIndexChangedint -->
<h3 class="fn" id="currentIndex-prop"><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>
<div class="table"><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></div>
<p><b>Notifier signal:</b></p>
<div class="table"><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></div>
<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" id="orientation-prop"><a name="orientation-prop"></a><span class="name">orientation</span> : <span class="type"><a href="../qtcore/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="../qtcore/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="../qtcore/qt.html#Orientation-enum">Qt::Horizontal</a> for tabular data that looks like this:</p>
<div class="table"><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></div>
<p>If the orientation is set to <a href="../qtcore/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="../qtcore/qt.html#Orientation-enum">Qt::Vertical</a> for tabular data that looks like this:</p>
<div class="table"><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></div>
<p>Changing the orientation clears all existing mappings.</p>
<p><b>Access functions:</b></p>
<div class="table"><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></div>
<!-- @@@orientation -->
<!-- $$$submitPolicy-prop$$$submitPolicy$$$setSubmitPolicySubmitPolicy -->
<h3 class="fn" id="submitPolicy-prop"><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>
<div class="table"><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></div>
<!-- @@@submitPolicy -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QDataWidgetMapper[overload1]$$$QDataWidgetMapperQObject* -->
<h3 class="fn" id="QDataWidgetMapper"><a name="QDataWidgetMapper"></a>QDataWidgetMapper::<span class="name">QDataWidgetMapper</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</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 <code>AutoSubmit</code>.</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" id="dtor.QDataWidgetMapper"><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" id="addMapping"><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 <code>myModel</code> 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> <code>nameLineEdit</code>, and the second is mapped to the <a href="qspinbox.html">QSpinBox</a> <code>ageSpinBox</code>:</p>
<pre class="cpp">

  <span class="type"><a href="qdatawidgetmapper.html#QDataWidgetMapper">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">QDataWidgetMapper</a></span>();
  mapper<span class="operator">-</span><span class="operator">&gt;</span>setModel(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" id="addMapping-1"><a name="addMapping-1"></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="../qtcore/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" id="clearMapping"><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 -->
<h3 class="fn" id="currentIndexChanged"><a name="currentIndexChanged"></a><code>[signal] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">currentIndexChanged</span>(<span class="type">int</span> <i>index</i>)</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>Note:</b> Notifier signal for property <a href="qdatawidgetmapper.html#currentIndex-prop">currentIndex</a>. </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" id="itemDelegate"><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" id="mappedPropertyName"><a name="mappedPropertyName"></a><span class="type"><a href="../qtcore/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" id="mappedSection"><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" id="mappedWidgetAt"><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" id="model"><a name="model"></a><span class="type"><a href="../qtcore/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" id="removeMapping"><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" id="revert"><a name="revert"></a><code>[slot] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">revert</span>()</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" id="rootIndex"><a name="rootIndex"></a><span class="type"><a href="../qtcore/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" id="setCurrentModelIndex"><a name="setCurrentModelIndex"></a><code>[slot] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">setCurrentModelIndex</span>(const <span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span> &amp;<i>index</i>)</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="../qtcore/qitemselectionmodel.html#currentRowChanged">currentRowChanged()</a> or <a href="../qtcore/qitemselectionmodel.html#currentColumnChanged">currentColumnChanged()</a> of another view's <a href="../qtcore/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 <code>myTableView</code> changes:</p>
<pre class="cpp">

  <span class="type"><a href="qdatawidgetmapper.html#QDataWidgetMapper">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">QDataWidgetMapper</a></span>();
  connect(myTableView<span class="operator">-</span><span class="operator">&gt;</span>selectionModel()<span class="operator">,</span> SIGNAL(currentRowChanged(<span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span><span class="operator">,</span><span class="type"><a href="../qtcore/qmodelindex.html">QModelIndex</a></span>))<span class="operator">,</span>
          mapper<span class="operator">,</span> SLOT(setCurrentModelIndex(<span class="type"><a href="../qtcore/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" id="setItemDelegate"><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" id="setModel"><a name="setModel"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">setModel</span>(<span class="type"><a href="../qtcore/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" id="setRootIndex"><a name="setRootIndex"></a><span class="type">void</span> QDataWidgetMapper::<span class="name">setRootIndex</span>(const <span class="type"><a href="../qtcore/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" id="submit"><a name="submit"></a><code>[slot] </code><span class="type">bool</span> QDataWidgetMapper::<span class="name">submit</span>()</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="../qtcore/qabstractitemmodel.html#submit">submit()</a> method is invoked.</p>
<p>Returns <code>true</code> if all the values were submitted, otherwise false.</p>
<p>Note: For database models, <a href="../qtsql/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" id="toFirst"><a name="toFirst"></a><code>[slot] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">toFirst</span>()</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 <code>setCurrentIndex(0)</code>.</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" id="toLast"><a name="toLast"></a><code>[slot] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">toLast</span>()</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" id="toNext"><a name="toNext"></a><code>[slot] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">toNext</span>()</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" id="toPrevious"><a name="toPrevious"></a><code>[slot] </code><span class="type">void</span> QDataWidgetMapper::<span class="name">toPrevious</span>()</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>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    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.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>