0

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!

2
Contributors
4
Replies
18
Views
2 Years
Discussion Span
Last Post by Odyssey2001
0

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.

0

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?

0

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.

0

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.