Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QDataWidgetMapper Class Reference

The QDataWidgetMapper class provides mapping between a section of a data model to widgets. More...

#include <qdatawidgetmapper.h>

+ Inheritance diagram for QDataWidgetMapper:
+ Collaboration diagram for QDataWidgetMapper:

Public Types

enum  SubmitPolicy { AutoSubmit , ManualSubmit }
 This enum describes the possible submit policies a QDataWidgetMapper supports. More...
 

Public Slots

void revert ()
 Repopulates all widgets with the current data of the model.
 
bool submit ()
 Submits all changes from the mapped widgets to the model.
 
void toFirst ()
 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.
 
void toLast ()
 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.
 
void toNext ()
 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.
 
void toPrevious ()
 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.
 
virtual void setCurrentIndex (int index)
 
void setCurrentModelIndex (const QModelIndex &index)
 Sets the current index to the row of the index if the orientation is horizontal (the default), otherwise to the column of the index.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 

Signals

void currentIndexChanged (int index)
 This signal is emitted after the current index has changed and all widgets were populated with new data.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QDataWidgetMapper (QObject *parent=nullptr)
 Constructs a new QDataWidgetMapper with parent object parent.
 
 ~QDataWidgetMapper ()
 Destroys the object.
 
void setModel (QAbstractItemModel *model)
 Sets the current model to model.
 
QAbstractItemModelmodel () const
 Returns the current model.
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate to delegate.
 
QAbstractItemDelegateitemDelegate () const
 Returns the current item delegate.
 
void setRootIndex (const QModelIndex &index)
 Sets the root item to index.
 
QModelIndex rootIndex () const
 Returns the current root index.
 
void setOrientation (Qt::Orientation aOrientation)
 
Qt::Orientation orientation () const
 
void setSubmitPolicy (SubmitPolicy policy)
 
SubmitPolicy submitPolicy () const
 
void addMapping (QWidget *widget, int section)
 Adds a mapping between a widget and a section from the model.
 
void addMapping (QWidget *widget, int section, const QByteArray &propertyName)
 
void removeMapping (QWidget *widget)
 Removes the mapping for the given widget.
 
int mappedSection (QWidget *widget) const
 Returns the section the widget is mapped to or -1 if the widget is not mapped.
 
QByteArray mappedPropertyName (QWidget *widget) const
 
QWidgetmappedWidgetAt (int section) const
 Returns the widget that is mapped at section, or 0 if no widget is mapped at that section.
 
void clearMapping ()
 Clears all mappings.
 
int currentIndex () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Properties

int currentIndex
 the current row or column
 
Qt::Orientation orientation
 the orientation of the model
 
SubmitPolicy submitPolicy
 the current submit policy
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QDataWidgetMapper class provides mapping between a section of a data model to widgets.

Since
4.2

\inmodule QtWidgets

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.

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 \l{Q_PROPERTY()}{user property} is used to transfer data between the model and the widget. Since Qt 4.3, an additional addMapping() function enables a named property to be used instead of the default user property.

It is possible to set an item delegate to support custom widgets. By default, a QStyledItemDelegate is used to synchronize the model with the widgets.

Let us assume that we have an item model named {model} with the following contents:

\table \row

  • 1
  • Qt Norway
  • Oslo \row
  • 2
  • Qt Australia
  • Brisbane \row
  • 3
  • Qt USA
  • Palo Alto \row
  • 4
  • Qt China
  • Beijing \row
  • 5
  • Qt Germany
  • Berlin \endtable

The following code will map the columns of the model to widgets called mySpinBox, myLineEdit and {myCountryChooser}:

mapper->addMapping(mySpinBox, 0);
mapper->addMapping(myLineEdit, 1);
mapper->addMapping(myCountryChooser, 2);

After the call to toFirst(), mySpinBox displays the value {1}, myLineEdit displays {Qt Norway} and myCountryChooser displays {Oslo}. The navigational functions toFirst(), toNext(), toPrevious(), toLast() and setCurrentIndex() can be used to navigate in the model and update the widgets with contents from the model.

The setRootIndex() 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.

QDataWidgetMapper supports two submit policies, AutoSubmit and {ManualSubmit}. AutoSubmit will update the model as soon as the current widget loses focus, ManualSubmit will not update the model unless submit() is called. ManualSubmit 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.

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.

See also
QAbstractItemModel, QAbstractItemDelegate

Definition at line 19 of file qdatawidgetmapper.h.

Member Enumeration Documentation

◆ SubmitPolicy

This enum describes the possible submit policies a QDataWidgetMapper supports.

\value AutoSubmit Whenever a widget loses focus, the widget's current value is set to the item model. \value ManualSubmit The model is not updated until submit() is called.

Enumerator
AutoSubmit 
ManualSubmit 

Definition at line 43 of file qdatawidgetmapper.h.

Constructor & Destructor Documentation

◆ QDataWidgetMapper()

QDataWidgetMapper::QDataWidgetMapper ( QObject * parent = nullptr)
explicit

Constructs a new QDataWidgetMapper with parent object parent.

By default, the orientation is horizontal and the submit policy is {AutoSubmit}.

See also
setOrientation(), setSubmitPolicy()

Definition at line 306 of file qdatawidgetmapper.cpp.

References setItemDelegate().

+ Here is the call graph for this function:

◆ ~QDataWidgetMapper()

QDataWidgetMapper::~QDataWidgetMapper ( )

Destroys the object.

Definition at line 315 of file qdatawidgetmapper.cpp.

References d.

Member Function Documentation

◆ addMapping() [1/2]

void QDataWidgetMapper::addMapping ( QWidget * widget,
int section )

Adds a mapping between a widget and a section from the model.

The section is a column in the model if the orientation is horizontal (the default), otherwise a row.

For the following example, we assume a model myModel 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 QLineEdit nameLineEdit, and the second is mapped to the QSpinBox {ageSpinBox}:

{Notes:} \list

  • If the widget is already mapped to a section, the old mapping will be replaced by the new one.
  • 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. \endlist
See also
removeMapping(), mappedSection(), clearMapping()

Definition at line 456 of file qdatawidgetmapper.cpp.

References d, QObject::installEventFilter(), QByteArray(), removeMapping(), and widget.

+ Here is the call graph for this function:

◆ addMapping() [2/2]

void QDataWidgetMapper::addMapping ( QWidget * widget,
int section,
const QByteArray & propertyName )
Since
4.3

Essentially the same as addMapping(), but adds the possibility to specify the property to use specifying propertyName.

See also
addMapping()

Definition at line 474 of file qdatawidgetmapper.cpp.

References d, QObject::installEventFilter(), removeMapping(), and widget.

+ Here is the call graph for this function:

◆ clearMapping()

void QDataWidgetMapper::clearMapping ( )

Clears all mappings.

See also
addMapping(), removeMapping()

Definition at line 724 of file qdatawidgetmapper.cpp.

References copy(), d, and it.

Referenced by setModel(), and setOrientation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentIndex()

int QDataWidgetMapper::currentIndex ( ) const

Definition at line 682 of file qdatawidgetmapper.cpp.

References d.

◆ currentIndexChanged

void QDataWidgetMapper::currentIndexChanged ( int index)
signal

This signal is emitted after the current index has changed and all widgets were populated with new data.

index is the new current index.

See also
currentIndex(), setCurrentIndex()

Referenced by setCurrentIndex().

+ Here is the caller graph for this function:

◆ itemDelegate()

QAbstractItemDelegate * QDataWidgetMapper::itemDelegate ( ) const

Returns the current item delegate.

Definition at line 402 of file qdatawidgetmapper.cpp.

References d.

◆ mappedPropertyName()

QByteArray QDataWidgetMapper::mappedPropertyName ( QWidget * widget) const
Since
4.3 Returns the name of the property that is used when mapping data to the given widget.
See also
mappedSection(), addMapping(), removeMapping()

Definition at line 525 of file qdatawidgetmapper.cpp.

References d, QByteArray(), and widget.

+ Here is the call graph for this function:

◆ mappedSection()

int QDataWidgetMapper::mappedSection ( QWidget * widget) const

Returns the section the widget is mapped to or -1 if the widget is not mapped.

See also
addMapping(), removeMapping()

Definition at line 506 of file qdatawidgetmapper.cpp.

References d, and widget.

◆ mappedWidgetAt()

QWidget * QDataWidgetMapper::mappedWidgetAt ( int section) const

Returns the widget that is mapped at section, or 0 if no widget is mapped at that section.

See also
addMapping(), removeMapping()

Definition at line 545 of file qdatawidgetmapper.cpp.

References d.

◆ model()

QAbstractItemModel * QDataWidgetMapper::model ( ) const

Returns the current model.

See also
setModel()

Definition at line 355 of file qdatawidgetmapper.cpp.

References d, and QAbstractItemModelPrivate::staticEmptyModel().

Referenced by setModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ orientation()

Qt::Orientation QDataWidgetMapper::orientation ( ) const

Definition at line 781 of file qdatawidgetmapper.cpp.

References d.

◆ removeMapping()

void QDataWidgetMapper::removeMapping ( QWidget * widget)

Removes the mapping for the given widget.

See also
addMapping(), clearMapping()

Definition at line 488 of file qdatawidgetmapper.cpp.

References d, QObject::removeEventFilter(), and widget.

Referenced by addMapping(), and addMapping().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ revert

void QDataWidgetMapper::revert ( )
slot

Repopulates all widgets with the current data of the model.

All unsubmitted changes will be lost.

See also
submit(), setSubmitPolicy()

Definition at line 563 of file qdatawidgetmapper.cpp.

References d.

Referenced by setSubmitPolicy().

+ Here is the caller graph for this function:

◆ rootIndex()

QModelIndex QDataWidgetMapper::rootIndex ( ) const

Returns the current root index.

See also
setRootIndex()

Definition at line 426 of file qdatawidgetmapper.cpp.

References d.

◆ setCurrentIndex

void QDataWidgetMapper::setCurrentIndex ( int index)
virtualslot

Definition at line 668 of file qdatawidgetmapper.cpp.

References currentIndexChanged(), d, emit, and Qt::Horizontal.

Referenced by setCurrentModelIndex(), toFirst(), toLast(), toNext(), and toPrevious().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCurrentModelIndex

void QDataWidgetMapper::setCurrentModelIndex ( const QModelIndex & index)
slot

Sets the current index to the row of the index if the orientation is horizontal (the default), otherwise to the column of the index.

Calls setCurrentIndex() internally. This convenience slot can be connected to the signal \l {QItemSelectionModel::}{currentRowChanged()} or \l {QItemSelectionModel::}{currentColumnChanged()} of another view's \l {QItemSelectionModel}{selection model}.

The following example illustrates how to update all widgets with new data whenever the selection of a QTableView named myTableView changes:

connect(myTableView->selectionModel(), &QItemSelectionModel::currentRowChanged,
The QDataWidgetMapper class provides mapping between a section of a data model to widgets.
void toFirst()
Populates the widgets with data from the first row of the model if the orientation is horizontal (the...
void addMapping(QWidget *widget, int section)
Adds a mapping between a widget and a section from the model.
void setCurrentModelIndex(const QModelIndex &index)
Sets the current index to the row of the index if the orientation is horizontal (the default),...
void setModel(QAbstractItemModel *model)
Sets the current model to model.
void currentRowChanged(const QModelIndex &current, const QModelIndex &previous)
This signal is emitted if the current item changes and its row is different to the row of the previou...
QSpinBox * ageSpinBox
QDataWidgetMapper * mapper
[0]
connect(myTableView->selectionModel(), &QItemSelectionModel::currentRowChanged, mapper, &QDataWidgetMapper::setCurrentModelIndex)
See also
currentIndex()

Definition at line 707 of file qdatawidgetmapper.cpp.

References d, Qt::Horizontal, and setCurrentIndex().

+ Here is the call graph for this function:

◆ setItemDelegate()

void QDataWidgetMapper::setItemDelegate ( QAbstractItemDelegate * delegate)

Sets the item delegate to delegate.

The delegate will be used to write data from the model into the widget and from the widget to the model, using QAbstractItemDelegate::setEditorData() and QAbstractItemDelegate::setModelData().

Any existing delegate will be removed, but not deleted. QDataWidgetMapper does not take ownership of delegate.

The delegate also decides when to apply data and when to change the editor, using QAbstractItemDelegate::commitData() and QAbstractItemDelegate::closeEditor().

Warning
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 \l{QAbstractItemDelegate::}{closeEditor()} signal, and attempt to access, modify or close an editor that has already been closed.

Definition at line 379 of file qdatawidgetmapper.cpp.

References QDataWidgetMapperPrivate::closeEditor(), QAbstractItemDelegate::closeEditor(), QDataWidgetMapperPrivate::commitData(), QAbstractItemDelegate::commitData(), QObjectPrivate::connect(), and d.

Referenced by QDataWidgetMapper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setModel()

void QDataWidgetMapper::setModel ( QAbstractItemModel * model)

Sets the current model to model.

If another model was set, all mappings to that old model are cleared.

See also
model()

Definition at line 328 of file qdatawidgetmapper.cpp.

References clearMapping(), QObjectPrivate::connect(), d, QDataWidgetMapperPrivate::dataChanged(), QAbstractItemModel::dataChanged(), QObject::destroyed(), model(), and QDataWidgetMapperPrivate::modelDestroyed().

+ Here is the call graph for this function:

◆ setOrientation()

void QDataWidgetMapper::setOrientation ( Qt::Orientation aOrientation)

Definition at line 770 of file qdatawidgetmapper.cpp.

References clearMapping(), d, and orientation.

+ Here is the call graph for this function:

◆ setRootIndex()

void QDataWidgetMapper::setRootIndex ( const QModelIndex & index)

Sets the root item to index.

This can be used to display a branch of a tree. Pass an invalid model index to display the top-most branch.

See also
rootIndex()

Definition at line 415 of file qdatawidgetmapper.cpp.

References d.

◆ setSubmitPolicy()

void QDataWidgetMapper::setSubmitPolicy ( SubmitPolicy policy)

Definition at line 794 of file qdatawidgetmapper.cpp.

References d, policy, and revert().

+ Here is the call graph for this function:

◆ submit

bool QDataWidgetMapper::submit ( )
slot

Submits all changes from the mapped widgets to the model.

For every mapped section, the item delegate reads the current value from the widget and sets it in the model. Finally, the model's \l {QAbstractItemModel::}{submit()} method is invoked.

Returns true if all the values were submitted, otherwise false.

Note: For database models, QSqlQueryModel::lastError() can be used to retrieve the last error.

See also
revert(), setSubmitPolicy()

Definition at line 584 of file qdatawidgetmapper.cpp.

References d.

◆ submitPolicy()

QDataWidgetMapper::SubmitPolicy QDataWidgetMapper::submitPolicy ( ) const

Definition at line 804 of file qdatawidgetmapper.cpp.

References d.

◆ toFirst

void QDataWidgetMapper::toFirst ( )
slot

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.

This is equivalent to calling setCurrentIndex(0).

See also
toLast(), setCurrentIndex()

Definition at line 605 of file qdatawidgetmapper.cpp.

References setCurrentIndex().

+ Here is the call graph for this function:

◆ toLast

void QDataWidgetMapper::toLast ( )
slot

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.

Calls setCurrentIndex() internally.

See also
toFirst(), setCurrentIndex()

Definition at line 619 of file qdatawidgetmapper.cpp.

References d, and setCurrentIndex().

+ Here is the call graph for this function:

◆ toNext

void QDataWidgetMapper::toNext ( )
slot

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.

Calls setCurrentIndex() internally. Does nothing if there is no next row in the model.

See also
toPrevious(), setCurrentIndex()

Definition at line 636 of file qdatawidgetmapper.cpp.

References d, and setCurrentIndex().

+ Here is the call graph for this function:

◆ toPrevious

void QDataWidgetMapper::toPrevious ( )
slot

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.

Calls setCurrentIndex() internally. Does nothing if there is no previous row in the model.

See also
toNext(), setCurrentIndex()

Definition at line 652 of file qdatawidgetmapper.cpp.

References d, and setCurrentIndex().

+ Here is the call graph for this function:

Property Documentation

◆ currentIndex

QDataWidgetMapper::currentIndex
readwrite

the current row or column

The widgets are populated with with data from the row at index if the orientation is horizontal (the default), otherwise with data from the column at index.

See also
setCurrentModelIndex(), toFirst(), toNext(), toPrevious(), toLast()

Definition at line 23 of file qdatawidgetmapper.h.

◆ orientation

QDataWidgetMapper::orientation
readwrite

the orientation of the model

If the orientation is Qt::Horizontal (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 currentIndex() points at.

Use Qt::Horizontal for tabular data that looks like this:

\table \row

  • 1
  • Qt Norway
  • Oslo \row
  • 2
  • Qt Australia
  • Brisbane \row
  • 3
  • Qt USA
  • Silicon Valley \row
  • 4
  • Qt China
  • Beijing \row
  • 5
  • Qt Germany
  • Berlin \endtable

If the orientation is set to Qt::Vertical, a widget is mapped to a row. Calling setCurrentIndex() will change the current column. The widget will be populates with the model's data from its mapped row and the column that currentIndex() points at.

Use Qt::Vertical for tabular data that looks like this:

\table \row

  • 1
  • 2
  • 3
  • 4
  • 5 \row
  • Qt Norway
  • Qt Australia
  • Qt USA
  • Qt China
  • Qt Germany \row
  • Oslo
  • Brisbane
  • Silicon Valley
  • Beijing
  • Berlin \endtable

Changing the orientation clears all existing mappings.

Definition at line 24 of file qdatawidgetmapper.h.

Referenced by setOrientation().

◆ submitPolicy

QDataWidgetMapper::submitPolicy
readwrite

the current submit policy

Changing the current submit policy will revert all widgets to the current data from the model.

Definition at line 25 of file qdatawidgetmapper.h.


The documentation for this class was generated from the following files: