hello ppl,
i'd like to visualize the contents of a small DB in a QTreeView.
the data in the database looks like the following example:
tbl_artist (ID INTEGER, NAME VARCHAR); ID is primary key
tbl_cd (ID INTEGER, NAME VARCHAR, ID_ARTIST); ID is primary key, ID_ARTIST foreing key
displaying this realation with a QSqlRelationalTableModel is pretty simple and would generally look like:
//we're inside a QWidget or QDialog or etc.
createDbConnection();
relModel->setTable("tbl_cd");
relModel
->setRelation
(2,
QSqlRelation("tbl_artist",
"ID",
"NAME"));
model->select();
m_tableView->setModel(relModel);
//we're inside a QWidget or QDialog or etc.
createDbConnection();
relModel = new QSqlRelationalTableModel(this);
relModel->setTable("tbl_cd");
relModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
relModel->setRelation(2, QSqlRelation("tbl_artist", "ID", "NAME"));
model->select();
m_tableView->setModel(relModel);
To copy to clipboard, switch view to plain text mode
i don't like the visualisation of the date inside a QTableView and would prefer the data to be arranged inside a QTreeview that would look like:
|
-artist1
| |-cd1
| |-cd2
|
-artist2
| |-cd1
..... i hope you get what i would like...
what i discovered so far is, that i have to use a QProxyModel to achieve it.
i searched the net and diverse forums to get an idea of how to use the QProxyModel, but found nothing that helped me further
i hope somebody here has the knowledge of how to link the 2 models.
i'd appreciate any help or suggestions.
greets
darksaga
Bookmarks