Hello,
I would like to have the data contained in an SQL table shown in a treeview (I already have that), but I would like items to be group (kind of filter) by types. See the exemple.
Here is my table "MultimediaFiles" structure:
- id,
- name,
- path,
- type (can be, "picture", "video", "sound").
So, I would like my records to be presented in a treeview like this :
|-- Name --|-- Path --|------------------------------------
- picture
|- foo.png C:\...- video
|- bar.avi C:\...- sound
|- toto.mpg C:\...
|- huhu.wav ...
|- haha.mp3 C:\...
What I already did :
Qt Code:
SQL::SQL() { mDb.setHostName( "localhost" ); mDb.setDatabaseName( "mydb" ); mDb.open(); setupModel(); } void SQL::setupModel() { pModel->setTable( "MultimediaFiles" ); if( !pModel->select() ) { qDebug() << "pb select"; qDebug() << pModel->lastError().text(); } treeView->setModel( pModel ); /*...*/ treeView->show(); }To copy to clipboard, switch view to plain text mode
But it doesn't act as I want : there is no node created.
So, do I miss something, or do I need to make my own model, or add treeItems by hands ?
Thanks in advance.
Bookmarks