Answer the question
In order to leave comments, you need to log in
why is there an error when working with tablerelationmodel in QT and SQLite? (resolved)
created 2 tables like this
Читатели:
Код SQL
CREATE TABLE readers(
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
id_book INTEGER,
age INTEGER,
FIO VARCHAR(10),
FOREIGN KEY(id_book) REFERENCES books(id)
);
Книги:
Код SQL
CREATE TABLE books(
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
price INTEGER,
COUNT INTEGER,
title VARCHAR(10)
);
QSqlRelationalTableModel* model = new QSqlRelationalTableModel(0);
model->setTable("readers");
model->setRelation(1,QSqlRelation("books", "id_book", "title")); //ASSERT тут ассерт.....
model->select();
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
ui->tableView->setModel(model);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question