本文整理汇总了C++中QSqlRelationalTableModel::match方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRelationalTableModel::match方法的具体用法?C++ QSqlRelationalTableModel::match怎么用?C++ QSqlRelationalTableModel::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlRelationalTableModel
的用法示例。
在下文中一共展示了QSqlRelationalTableModel::match方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addOrEditTreeItem
void MainWindow::addOrEditTreeItem(DialogMode mode, TreeItem treeItem, const QModelIndex &index)
{
const int eventsTableRow = rootModelIndex(index).row();
int eventsTableColumn = -1;
int itemTableNameColumn = -1;
QSqlRelationalTableModel *tableModel = 0;
SqlRelationalTableDialog *tableDialog = 0;
switch (treeItem) {
case CharacterItem:
eventsTableColumn = 2;
itemTableNameColumn = 1;
tableModel = database->characters();
tableDialog = new CharacterDialog(tableModel, this);
break;
case ConversationItem:
eventsTableColumn = 3;
itemTableNameColumn = 3;
tableModel = database->conversations();
tableDialog = new ConversationDialog(tableModel, this);
break;
}
QModelIndex eventsIndex =
database->events()->index(eventsTableRow, eventsTableColumn);
const QString &conversation = eventsIndex.data().toString();
QModelIndex firstItem =
tableModel->index(0, itemTableNameColumn);
QModelIndexList itemIndexes =
tableModel->match(firstItem, Qt::DisplayRole, conversation);
//Q_ASSERT(!itemIndexes.isEmpty());
//if (itemIndexes.isEmpty())
// return;
QModelIndex itemIndex;
if (!itemIndexes.isEmpty())
itemIndex = itemIndexes.first();
editViewItem(itemIndex, tableDialog, mode);
}