本文整理汇总了C++中QDataWidgetMapper类的典型用法代码示例。如果您正苦于以下问题:C++ QDataWidgetMapper类的具体用法?C++ QDataWidgetMapper怎么用?C++ QDataWidgetMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDataWidgetMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sipKeepReference
static PyObject *meth_QDataWidgetMapper_setModel(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QAbstractItemModel* a0;
PyObject *a0Keep;
QDataWidgetMapper *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "[email protected]", &sipSelf, sipType_QDataWidgetMapper, &sipCpp, &a0Keep, sipType_QAbstractItemModel, &a0))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->setModel(a0);
Py_END_ALLOW_THREADS
sipKeepReference(sipSelf, -20, a0Keep);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QDataWidgetMapper, sipName_setModel, doc_QDataWidgetMapper_setModel);
return NULL;
}
示例2: QDataWidgetMapper
void WalletStatusBar::setNodeStateModel(QAbstractItemModel* _model) {
m_nodeStateModel = _model;
QDataWidgetMapper* stateMapper = new QDataWidgetMapper(this);
stateMapper->setModel(m_nodeStateModel);
stateMapper->addMapping(m_peerCountLabel, NodeStateModel::COLUMN_PEER_COUNT, "text");
stateMapper->setCurrentIndex(0);
connect(m_nodeStateModel, &QAbstractItemModel::dataChanged, this, &WalletStatusBar::nodeStateChanged);
}
示例3: getQDataWidgetMapperList
// Svuota la lista corrispondente a tableName contenente
// oggetti QDataWidgetMapper. Inoltre de-alloca la memoria dei modelli
// a cui questi mapper si riferiscono
void FormPerson::emptyQDataWidgetMapper(QString tableName)
{
QList<QDataWidgetMapper *> *list;
list = getQDataWidgetMapperList(tableName);
while (!list->isEmpty())
{
QDataWidgetMapper *mapper = (QDataWidgetMapper *) list->takeFirst();
delete mapper->model();
delete mapper;
}
}
示例4: QSqlTableModel
void FormPerson::loadLayout(QString tableName)
{
// Recupero link al database
QSqlDatabase db = QSqlDatabase::database("ConnectionToDB");
// Creo un modello sche si riferirà alla tabella delle mail
QSqlTableModel *model = new QSqlTableModel(this, db);
// Imposto la tabella a cui si riferirà il modello
model->setTable(tableName);
// Imposto un filtro sulla persona a cui la tabella è collegata
model->setFilter("id_person=" + QString::number(this->personId));
model->select();
// Per ciascuna riga della tabella...
for (int i=0; i<model->rowCount(); i++)
{
QHBoxLayout *hbl = new QHBoxLayout();
// Creo un nuovo oggetto QLineEdit
QLineEdit *qlineedit = new QLineEdit();
// Creo un pulsante per la successiva rimozione dell'entry nel database
RemoveRowFromModel *button = new RemoveRowFromModel(i, model, tableName);
// Collego il pulante alla funzione di refresh
QObject::connect(button, SIGNAL(rowRemoved(QString)), this, SLOT(refreshLayout(QString)));
// Creo un mapper
QDataWidgetMapper *mapperEmailPerson = new QDataWidgetMapper();
// Collego al mapper il modello della tabella
mapperEmailPerson->setModel(model);
// Aggiungo un mapping tra l'oggetto QLineEdit e il modello
mapperEmailPerson->addMapping(qlineedit, 1);
// Posiziono il mapper sull'indice opportuno
mapperEmailPerson->setCurrentIndex(i);
// Inserisco il mapper nella lista dei mapper per le email
getQDataWidgetMapperList(tableName)->append(mapperEmailPerson);
// qlineedit e button, li visualizzo sulla stessa riga (li inserisco in un layout orizzontale)
hbl->addWidget(qlineedit);
hbl->addWidget(button);
// Inserisco il layout orizzontale nel layout delle mail
getVerticalLayout(tableName)->addLayout(hbl);
// Collego il pulsante ad uno slot, in modo che venga gestita la rimozione di una riga dal
// modello
}
}
示例5: setData
void tst_QDataWidgetMapper::setData()
{
QDataWidgetMapper mapper;
QAbstractItemModel *model = testModel(&mapper);
mapper.setModel(model);
QLineEdit edit1;
QLineEdit edit2;
QLineEdit edit3;
mapper.addMapping(&edit1, 0);
mapper.addMapping(&edit2, 1);
mapper.addMapping(&edit3, 0, "text");
mapper.toFirst();
QCOMPARE(edit1.text(), QString("item 0 0"));
QCOMPARE(edit2.text(), QString("item 0 1"));
QCOMPARE(edit3.text(), QString("item 0 0"));
edit1.setText("new text");
mapper.submit();
QCOMPARE(model->data(model->index(0, 0)).toString(), QString("new text"));
edit3.setText("more text");
mapper.submit();
QCOMPARE(model->data(model->index(0, 0)).toString(), QString("more text"));
}
示例6: currentIndexChanged
void tst_QDataWidgetMapper::currentIndexChanged()
{
QDataWidgetMapper mapper;
QAbstractItemModel *model = testModel(&mapper);
mapper.setModel(model);
QSignalSpy spy(&mapper, SIGNAL(currentIndexChanged(int)));
mapper.toFirst();
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).toInt(), 0);
mapper.toNext();
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).toInt(), 1);
mapper.setCurrentIndex(7);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).toInt(), 7);
mapper.setCurrentIndex(-1);
QCOMPARE(spy.count(), 0);
mapper.setCurrentIndex(42);
QCOMPARE(spy.count(), 0);
}
示例7: QDialog
InfoDialog::InfoDialog(QWidget *parent, int user_id, int num) :
QDialog(parent),
ui(new Ui::InfoDialog)
{
ui->setupUi(this);
setWindowTitle("我的借阅信息");
currentUserId = user_id;
num_can_borrow = num;
model = new QSqlRelationalTableModel(ui->tableView);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setTable("borrowed_books");
model->setRelation(model->fieldIndex("book_id"), QSqlRelation("books", "id", "title"));
model->setHeaderData(model->fieldIndex("book_id"), Qt::Horizontal, tr("名称"));
model->setHeaderData(model->fieldIndex("start_time"), Qt::Horizontal, tr("借阅起始时间"));
model->setHeaderData(model->fieldIndex("end_time"), Qt::Horizontal, tr("借阅到期时间"));
ui->tableView->setModel(model);
ui->tableView->setColumnHidden(model->fieldIndex("id"), true);
ui->tableView->setColumnHidden(model->fieldIndex("user_id"), true);
ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
idHiddenWidget = new QLineEdit(this);
idHiddenWidget->setVisible(false);
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->addMapping(idHiddenWidget, model->fieldIndex("id"));
connect(ui->tableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
model->setFilter("user_id='" + QString::number(currentUserId) + "'");
model->select();
connect(ui->getbackButton, SIGNAL(clicked()), this, SLOT(getback()));
connect(ui->confirmButton, SIGNAL(clicked()), this, SLOT(confirm()));
}
示例8: QCOMPARE
void tst_QDataWidgetMapper::setModel()
{
QDataWidgetMapper mapper;
QCOMPARE(mapper.model(), (QAbstractItemModel *)0);
{ // let the model go out of scope firstma
QStandardItemModel model;
mapper.setModel(&model);
QCOMPARE(mapper.model(), static_cast<QAbstractItemModel *>(&model));
}
QCOMPARE(mapper.model(), (QAbstractItemModel *)0);
{ // let the mapper go out of scope first
QStandardItemModel model2;
QDataWidgetMapper mapper2;
mapper2.setModel(&model2);
}
}
示例9: QWidget
QWidget* MainWindow::createForm(QAbstractTableModel* model) {
QWidget* form = new QWidget();
QGridLayout* grid = new QGridLayout();
QLineEdit* edtName = new QLineEdit();
QLineEdit* edtComment = new QLineEdit();
QSpinBox* spnSensitivity = new QSpinBox();
int iRow = 0;
grid->addWidget(new QLabel(tr("Name:")), iRow, 0);
grid->addWidget(edtName, iRow++, 1);
grid->addWidget(new QLabel(tr("Comment:")), iRow, 0);
grid->addWidget(edtComment, iRow++, 1);
grid->addWidget(new QLabel(tr("Sensitivity:")), iRow, 0);
grid->addWidget(spnSensitivity, iRow++, 1);
QDataWidgetMapper* mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->addMapping(edtName, 0);
mapper->addMapping(edtComment, 1);
mapper->addMapping(spnSensitivity, 2);
mapper->toFirst();
form->setLayout(grid);
return form;
}
示例10: mappedWidgetAt
void tst_QDataWidgetMapper::mappedWidgetAt()
{
QDataWidgetMapper mapper;
QAbstractItemModel *model = testModel(&mapper);
mapper.setModel(model);
QLineEdit lineEdit1;
QLineEdit lineEdit2;
QCOMPARE(mapper.mappedWidgetAt(432312), (QWidget*)0);
mapper.addMapping(&lineEdit1, 1);
mapper.addMapping(&lineEdit2, 2);
QCOMPARE(mapper.mappedWidgetAt(1), static_cast<QWidget *>(&lineEdit1));
QCOMPARE(mapper.mappedWidgetAt(2), static_cast<QWidget *>(&lineEdit2));
mapper.addMapping(&lineEdit2, 4242);
QCOMPARE(mapper.mappedWidgetAt(2), (QWidget*)0);
QCOMPARE(mapper.mappedWidgetAt(4242), static_cast<QWidget *>(&lineEdit2));
}
示例11: testModel
void tst_QDataWidgetMapper::comboBox()
{
QDataWidgetMapper mapper;
QAbstractItemModel *model = testModel(&mapper);
mapper.setModel(model);
mapper.setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
QComboBox readOnlyBox;
readOnlyBox.setEditable(false);
readOnlyBox.addItem("read only item 0");
readOnlyBox.addItem("read only item 1");
readOnlyBox.addItem("read only item 2");
QComboBox readWriteBox;
readWriteBox.setEditable(true);
readWriteBox.addItem("read write item 0");
readWriteBox.addItem("read write item 1");
readWriteBox.addItem("read write item 2");
// populat the combo boxes with data
mapper.addMapping(&readOnlyBox, 0, "currentIndex");
mapper.addMapping(&readWriteBox, 1, "currentText");
mapper.toFirst();
QCOMPARE(readOnlyBox.currentText(), QString("read only item 0"));
QCOMPARE(readWriteBox.currentText(), QString("read write item 0"));
// set some new values on the boxes
readOnlyBox.setCurrentIndex(1);
readWriteBox.setEditText("read write item y");
mapper.submit();
// make sure the new values are in the model
QCOMPARE(model->data(model->index(0, 0)).toInt(), 1);
QCOMPARE(model->data(model->index(0, 1)).toString(), QString("read write item y"));
// now test updating of the widgets
model->setData(model->index(0, 0), 2, Qt::EditRole);
model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole);
QCOMPARE(readOnlyBox.currentIndex(), 2);
QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort);
QCOMPARE(readWriteBox.currentText(), QString("read write item z"));
}
示例12: changingValues
void tst_QDataWidgetMapper::changingValues()
{
QDataWidgetMapper mapper;
QAbstractItemModel *model = testModel(&mapper);
mapper.setModel(model);
QLineEdit edit1;
mapper.addMapping(&edit1, 0);
mapper.toFirst();
QCOMPARE(edit1.text(), QString("item 0 0"));
QLineEdit edit2;
mapper.addMapping(&edit2, 0, "text");
mapper.toFirst();
QCOMPARE(edit2.text(), QString("item 0 0"));
model->setData(model->index(0, 0), QString("changed"));
QCOMPARE(edit1.text(), QString("changed"));
QCOMPARE(edit2.text(), QString("changed"));
}
示例13: initDb
BookWindow::BookWindow()
{
ui.setupUi(this);
if (!QSqlDatabase::drivers().contains("QSQLITE"))
QMessageBox::critical(this, "Unable to load database", "This demo needs the SQLITE driver");
// initialize the database
QSqlError err = initDb();
if (err.type() != QSqlError::NoError) {
showError(err);
return;
}
// Create the data model
model = new QSqlRelationalTableModel(ui.bookTable);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setTable("books");
// Remember the indexes of the columns
authorIdx = model->fieldIndex("author");
genreIdx = model->fieldIndex("genre");
// Set the relations to the other database tables
model->setRelation(authorIdx, QSqlRelation("authors", "id", "name"));
model->setRelation(genreIdx, QSqlRelation("genres", "id", "name"));
// Set the localized header captions
model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
model->setHeaderData(model->fieldIndex("title"), Qt::Horizontal, tr("Title"));
model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
model->setHeaderData(model->fieldIndex("rating"), Qt::Horizontal, tr("Rating"));
// Populate the model
if (!model->select()) {
showError(model->lastError());
return;
}
// Set the model and hide the ID column
ui.bookTable->setModel(model);
ui.bookTable->setItemDelegate(new BookDelegate(ui.bookTable));
ui.bookTable->setColumnHidden(model->fieldIndex("id"), true);
ui.bookTable->setSelectionMode(QAbstractItemView::SingleSelection);
// Initialize the Author combo box
ui.authorEdit->setModel(model->relationModel(authorIdx));
ui.authorEdit->setModelColumn(model->relationModel(authorIdx)->fieldIndex("name"));
ui.genreEdit->setModel(model->relationModel(genreIdx));
ui.genreEdit->setModelColumn(model->relationModel(genreIdx)->fieldIndex("name"));
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->setItemDelegate(new BookDelegate(this));
mapper->addMapping(ui.titleEdit, model->fieldIndex("title"));
mapper->addMapping(ui.yearEdit, model->fieldIndex("year"));
mapper->addMapping(ui.authorEdit, authorIdx);
mapper->addMapping(ui.genreEdit, genreIdx);
mapper->addMapping(ui.ratingEdit, model->fieldIndex("rating"));
connect(ui.bookTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
ui.bookTable->setCurrentIndex(model->index(0, 0));
}
示例14: QDialog
SaveStreamDialog::SaveStreamDialog(StreamTableModel *model, const QHash<QString, QVariant> &settings, const QString &streamTitle, QWidget *parent):
QDialog(parent)
{
this->settings = settings;
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QHBoxLayout *buttonLayout = new QHBoxLayout();
QFormLayout *formLayout = new QFormLayout();
QDataWidgetMapper *dataMapper = new QDataWidgetMapper(this);
editFileName = new FilePathEdit(this);
QLabel *suffixHint = new QLabel(this);
checkSubtitles = new QCheckBox("Ladda ner undertexter till:", this);
checkSubtitles->hide();
editSubFileName = new FilePathEdit(this);
editSubFileName->setEnabled(false);
editSubFileName->hide();
comboQuality = new QComboBox(this);
editStreamUrl = new QLineEdit(this);
editStreamUrl->hide();
editSubUrl = new QLineEdit(this);
editSubUrl->hide();
editSubUrl->setEnabled(false);
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setGeometry(QRect(320, 150, 118, 3));
line->setFrameShadow(QFrame::Sunken);
QCheckBox *checkEdit = new QCheckBox(QString::fromUtf8("Redigera addresser"), this);
QPushButton *buttonPlay = new QPushButton("Spela upp", this);
buttonSubmit = new QPushButton("Ladda ner", this);
buttonSubmit->setDefault(true);
QPushButton *buttonCancel = new QPushButton("Avbryt", this);
connect(checkEdit, SIGNAL(clicked(bool)), editStreamUrl, SLOT(setVisible(bool)));
connect(checkEdit, SIGNAL(clicked(bool)), editSubUrl, SLOT(setVisible(bool)));
connect(buttonSubmit, SIGNAL(clicked()), this, SLOT(checkOverWrite()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(comboQuality, SIGNAL(currentIndexChanged(int)), dataMapper, SLOT(setCurrentIndex(int)));
connect(comboQuality, SIGNAL(currentIndexChanged(int)), this, SLOT(comboActivated(int)));
connect(checkSubtitles, SIGNAL(clicked(bool)), editSubFileName, SLOT(setEnabled(bool)));
connect(checkSubtitles, SIGNAL(clicked(bool)), editSubUrl, SLOT(setEnabled(bool)));
connect(checkSubtitles, SIGNAL(clicked(bool)), this, SLOT(enableSubmit()));
connect(editFileName, SIGNAL(pathValid(bool)), this, SLOT(enableSubmit()));
connect(editFileName, SIGNAL(dirChanged(QString)), editSubFileName, SLOT(setDir(QString)));
connect(editSubFileName, SIGNAL(pathValid(bool)), this, SLOT(enableSubmit()));
connect(buttonPlay, SIGNAL(clicked()), this, SLOT(play()));
QString filenameTemplate = settings.value("filename_template").toString();
const QStringList templateVars = QStringList() << "title" << "name" << "time" << "season" << "description";
for (int i=0; i<templateVars.count(); i++)
filenameTemplate.replace("%" % templateVars.at(i) % "%", "%" % QString::number(i));
QString fileName = filenameTemplate;
QVariantMap metaData = model->metaData();
for (int i=0; i<templateVars.count(); i++)
fileName = fileName.arg(metaData.value(templateVars.at(i), "").toString());
QString nullFileName = filenameTemplate;
for (int i=0; i<templateVars.count(); i++)
nullFileName = nullFileName.arg("");
if (fileName != nullFileName) {
QString suffix = model->data(model->index(0, StreamTableModel::SuffixHintColumn), Qt::UserRole).toString();
suffix = !suffix.isEmpty() ? '.' % suffix : suffix;
bool addSlash = !settings["start_dir"].toString().endsWith(QDir::separator());
editFileName->setFilePath(settings["start_dir"].toString() % (addSlash ? (QString)QDir::separator() : "") % fileName % suffix);
editSubFileName->setFilePath(settings["start_dir"].toString() % (addSlash ? (QString)QDir::separator() : "") % fileName);
}
else {
editFileName->setFilePath(settings["start_dir"].toString());
editSubFileName->setFilePath(settings["start_dir"].toString());
}
dataMapper->setModel(model);
dataMapper->setCurrentIndex(comboQuality->currentIndex());
dataMapper->addMapping(editStreamUrl, StreamTableModel::UrlColumn);
dataMapper->addMapping(editSubUrl, StreamTableModel::SubtitlesColumn);
dataMapper->addMapping(suffixHint, StreamTableModel::SuffixHintColumn, "text");
comboQuality->setModel(model);
formLayout->addRow("Ladda ner till:", editFileName);
formLayout->addRow("", suffixHint);
formLayout->addRow("Kvalitet:", comboQuality);
formLayout->addRow("", editStreamUrl);
formLayout->addRow(checkSubtitles, editSubFileName);
formLayout->addRow("", editSubUrl);
buttonLayout->addWidget(checkEdit);
buttonLayout->addStretch(1);
buttonLayout->addWidget(buttonPlay);
buttonLayout->addWidget(buttonSubmit);
buttonLayout->addWidget(buttonCancel);
mainLayout->addLayout(formLayout);
mainLayout->addWidget(line);
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
setWindowTitle(QString::fromUtf8("Spara ström - ") + streamTitle);
setMinimumWidth(500);
//.........这里部分代码省略.........
示例15: navigate
void tst_QDataWidgetMapper::navigate()
{
QDataWidgetMapper mapper;
QAbstractItemModel *model = testModel(&mapper);
mapper.setModel(model);
QLineEdit edit1;
QLineEdit edit2;
QLineEdit edit3;
mapper.addMapping(&edit1, 0);
mapper.toFirst();
mapper.addMapping(&edit2, 1);
mapper.addMapping(&edit3, 2);
QCOMPARE(edit1.text(), QString("item 0 0"));
QVERIFY(edit2.text().isEmpty());
QVERIFY(edit3.text().isEmpty());
QVERIFY(mapper.submit());
edit2.setText(QString("item 0 1"));
edit3.setText(QString("item 0 2"));
QVERIFY(mapper.submit());
mapper.toFirst(); //this will repopulate
QCOMPARE(edit1.text(), QString("item 0 0"));
QCOMPARE(edit2.text(), QString("item 0 1"));
QCOMPARE(edit3.text(), QString("item 0 2"));
mapper.toFirst();
QCOMPARE(edit1.text(), QString("item 0 0"));
QCOMPARE(edit2.text(), QString("item 0 1"));
QCOMPARE(edit3.text(), QString("item 0 2"));
mapper.toPrevious(); // should do nothing
QCOMPARE(edit1.text(), QString("item 0 0"));
QCOMPARE(edit2.text(), QString("item 0 1"));
QCOMPARE(edit3.text(), QString("item 0 2"));
mapper.toNext();
QCOMPARE(edit1.text(), QString("item 1 0"));
QCOMPARE(edit2.text(), QString("item 1 1"));
QCOMPARE(edit3.text(), QString("item 1 2"));
mapper.toLast();
QCOMPARE(edit1.text(), QString("item 9 0"));
QCOMPARE(edit2.text(), QString("item 9 1"));
QCOMPARE(edit3.text(), QString("item 9 2"));
mapper.toNext(); // should do nothing
QCOMPARE(edit1.text(), QString("item 9 0"));
QCOMPARE(edit2.text(), QString("item 9 1"));
QCOMPARE(edit3.text(), QString("item 9 2"));
mapper.setCurrentIndex(4);
QCOMPARE(edit1.text(), QString("item 4 0"));
QCOMPARE(edit2.text(), QString("item 4 1"));
QCOMPARE(edit3.text(), QString("item 4 2"));
mapper.setCurrentIndex(-1); // should do nothing
QCOMPARE(edit1.text(), QString("item 4 0"));
QCOMPARE(edit2.text(), QString("item 4 1"));
QCOMPARE(edit3.text(), QString("item 4 2"));
mapper.setCurrentIndex(10); // should do nothing
QCOMPARE(edit1.text(), QString("item 4 0"));
QCOMPARE(edit2.text(), QString("item 4 1"));
QCOMPARE(edit3.text(), QString("item 4 2"));
mapper.setCurrentModelIndex(QModelIndex()); // should do nothing
QCOMPARE(edit1.text(), QString("item 4 0"));
QCOMPARE(edit2.text(), QString("item 4 1"));
QCOMPARE(edit3.text(), QString("item 4 2"));
mapper.setCurrentModelIndex(model->index(6, 0));
QCOMPARE(edit1.text(), QString("item 6 0"));
QCOMPARE(edit2.text(), QString("item 6 1"));
QCOMPARE(edit3.text(), QString("item 6 2"));
/* now try vertical navigation */
mapper.setOrientation(Qt::Vertical);
mapper.addMapping(&edit1, 0);
mapper.addMapping(&edit2, 1);
mapper.addMapping(&edit3, 2);
mapper.toFirst();
QCOMPARE(edit1.text(), QString("item 0 0"));
QCOMPARE(edit2.text(), QString("item 1 0"));
QCOMPARE(edit3.text(), QString("item 2 0"));
mapper.toPrevious(); // should do nothing
QCOMPARE(edit1.text(), QString("item 0 0"));
QCOMPARE(edit2.text(), QString("item 1 0"));
QCOMPARE(edit3.text(), QString("item 2 0"));
mapper.toNext();
QCOMPARE(edit1.text(), QString("item 0 1"));
QCOMPARE(edit2.text(), QString("item 1 1"));
//.........这里部分代码省略.........