Hello!!I have a database and I want to display its data into a QTreeView in PyQt.The database's column has file paths.I have a problem in filling this treeview with data because it's a database and I'm not sure if it is like working with txt files and because it is file paths.I heard that I should use proxy models,but I am not sure how to do this or if this is the right thing to do and I can't find any relevant examples...I would appreciate any help.Thank you in advance!

Recommended Answers

The only different with working with a database and tree view is the heirarchy in the database needs to be interpreted.

Normally, this comes in the form of a parent child relationship. If you recurse through that you should be able to build your tree view.

Jump to Post

All 4 Replies

The only different with working with a database and tree view is the heirarchy in the database needs to be interpreted.

Normally, this comes in the form of a parent child relationship. If you recurse through that you should be able to build your tree view.

Thank you!Sorry for bothering you again,but could you show me an example so that I can understand better what I should do?And about the file paths,should I treat them differently?

Not sure what you mean by file paths.

An example would be in your database you would have a parent child relationship

name  id  parentid
bob   1   1
sara  2   1

In the above example sara would fall under bob as bob is the parent. How you display that in a treeview I wouldn't know. I don't use python.

It's that in my database I have file paths.I once saw an example somewhere,and they used QFileSystemModel and proxy models.But I don't think that this would work for me,as I don't have full paths.
Ok,thanks anyway!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.