Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
src_gui_itemviews_qdatawidgetmapper.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5
QDataWidgetMapper
*
mapper
=
new
QDataWidgetMapper
;
6
mapper
->
setModel
(
model
);
7
mapper
->
addMapping
(mySpinBox, 0);
8
mapper
->
addMapping
(myLineEdit, 1);
9
mapper
->
addMapping
(myCountryChooser, 2);
10
mapper
->
toFirst
();
12
13
15
QDataWidgetMapper
*
mapper
=
new
QDataWidgetMapper
;
16
mapper
->
setModel
(myModel);
17
mapper
->
addMapping
(nameLineEdit, 0);
18
mapper
->
addMapping
(
ageSpinBox
, 1);
20
21
23
QDataWidgetMapper
*
mapper
=
new
QDataWidgetMapper
;
24
connect
(myTableView->selectionModel(), &
QItemSelectionModel::currentRowChanged
,
25
mapper
, &
QDataWidgetMapper::setCurrentModelIndex
);
QDataWidgetMapper
The QDataWidgetMapper class provides mapping between a section of a data model to widgets.
Definition
qdatawidgetmapper.h:20
QDataWidgetMapper::toFirst
void toFirst()
Populates the widgets with data from the first row of the model if the orientation is horizontal (the...
Definition
qdatawidgetmapper.cpp:590
QDataWidgetMapper::addMapping
void addMapping(QWidget *widget, int section)
Adds a mapping between a widget and a section from the model.
Definition
qdatawidgetmapper.cpp:441
QDataWidgetMapper::setCurrentModelIndex
void setCurrentModelIndex(const QModelIndex &index)
Sets the current index to the row of the index if the orientation is horizontal (the default),...
Definition
qdatawidgetmapper.cpp:692
QDataWidgetMapper::setModel
void setModel(QAbstractItemModel *model)
Sets the current model to model.
Definition
qdatawidgetmapper.cpp:310
QItemSelectionModel::currentRowChanged
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
This signal is emitted if the current item changes and its row is different to the row of the previou...
ageSpinBox
QSpinBox * ageSpinBox
Definition
doc_src_stylesheet.cpp:101
model
QSqlQueryModel * model
[16]
Definition
sqldatabase_snippet.cpp:5
mapper
QDataWidgetMapper * mapper
[0]
Definition
src_gui_itemviews_qdatawidgetmapper.cpp:5
connect
connect(myTableView->selectionModel(), &QItemSelectionModel::currentRowChanged, mapper, &QDataWidgetMapper::setCurrentModelIndex)
qtbase
src
widgets
doc
snippets
code
src_gui_itemviews_qdatawidgetmapper.cpp
Generated by
1.9.7