本文整理汇总了C++中QStandardItemModel::blockSignals方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItemModel::blockSignals方法的具体用法?C++ QStandardItemModel::blockSignals怎么用?C++ QStandardItemModel::blockSignals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel::blockSignals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setModelData
void DeliverOrderDelegate::setModelData(
QWidget *editor, QAbstractItemModel * model, const QModelIndex &index) const
{
QStandardItemModel * sModel = qobject_cast<QStandardItemModel *>(model);
if (0 == index.column()) {
FindClientDialog * w = qobject_cast<FindClientDialog *>(editor);
if (QDialog::Accepted == w->result() && !w->foundClient().isEmpty())
sModel->itemFromIndex(index)->setText(w->foundClient());
} else if (2 == index.column()) {
// Select product.
FindProductDialog * w = qobject_cast<FindProductDialog *>(editor);
const data::Product & product = w->foundProduct();
if (-1 == product.id || QDialog::Accepted != w->result())
return;
sModel->blockSignals(true);
sModel->item(index.row(), 1)->setText(product.category.name);
sModel->item(index.row(), 4)->setText(product.unit);
sModel->blockSignals(false);
sModel->itemFromIndex(index)->setText(product.name);
} else if (3 == index.column()) {
QSpinBox * w = qobject_cast<QSpinBox *>(editor);
sModel->itemFromIndex(index)->setText(QString("%1").arg(w->value()));
} else if (5 == index.column()) {
QLineEdit * w = qobject_cast<QLineEdit *>(editor);
sModel->itemFromIndex(index)->setText(w->text());
} else {
return QStyledItemDelegate::setEditorData(editor, index);
}
}