ingredientsModel = new RecipeIngredientsModel(this); ingredientsModel->setTable("recipes_ingredients"); ingredientsModel->setFilter("recipe_id='-1'"); ingredientsModel->setEditStrategy(QSqlTableModel::OnManualSubmit); ingredientsModel->setRelation(3, QSqlRelation("units","id","name")); ingredientsModel->setRelation(4, QSqlRelation("ingredients","id","name")); ingredientsModel->setHeaderData(2, Qt::Horizontal, tr("Количество")); ingredientsModel->setHeaderData(3, Qt::Horizontal, tr("Мера")); ingredientsModel->setHeaderData(4, Qt::Horizontal, tr("Ингредиент")); ingredientsModel->select();
QSqlTableModel * QSqlRelationalTableModel::relationModel ( int column ) const
ingredientsModel->relationModel(3)->select(); ingredientsModel->relationModel(4)->select();