JokerMartini
JokerMartini

Reputation: 6147

QTreeView, QTreeWidget, QTableWidget or QTableView for object data?

I have a collection of objects and I want to display their data in rows/columns. However, I'm not sure which PySide widget to use. There are a few main features I want to implement which I'm assuming may help decide which widget to use. Each row is an object. Which PySide widget should I use and why?

Features wanted:

[Desired display of data in columns and rows1

Upvotes: 1

Views: 1172

Answers (1)

titusjan
titusjan

Reputation: 5546

Use a tree if the data is hierarchical. Your data is clearly not so it's better to use a table.

The QTableWidget is slightly easier to implement than the QTableView (which also needs a QTableModel as backend) but it has less capabilities. I use a QTableWidget for simple cases and a QTableView when I need to. Reasons for using a QTableView can be to improve performance for large tables, or if I want multiple tables looking at the same data.

I think you can not do searching and filtering with a QTableWidget so you would have to use a QTableView.

Upvotes: 2

Related Questions