I am trying to create a QML Clothing application that uses an SQL database. What I am trying to do is have different clothing types like pants or shirts that when clicked open up each clothing item that is associated with that type. An example is when pants is clicked it expands and shows up Jeans.
The two tables in SQL:
CREATE TABLE ClothesTypes(typeId INTEGER PRIMARY KEY AUTOINCREMENT, typeName TEXT NOT NULL);CREATE TABLE Clothes(clothingId INTEGER PRIMARY KEY AUTOINCREMENT, clothingName TEXT NOT NULL, typeId INTEGER, FOREIGN KEY (typeId) REFERENCES ClothesTypes(typeId));
For that reason I wanted to use a TreeView. But I cant seem to grasp how to integrate it using SQL. First I thought of using QSqlRelationalTableModel but it seems like its only use is if i want the Clothes table to show first and the foreign key to have the name of the type and not the id like so:
setTable("Clothes");setRelation(2, QSqlRelation("ClothesTypes", "typeId", "typeName"));
Since its of no use to me I was thinking of using DelegateChooser with a TableView so when i click at a type it opens up another delegate. But that seems like a roundabout way of doing it.
Is there something else I can use to achieve this?Thanks!