PDA

View Full Version : QTreeView like excel spreadsheet



Stapl
13th September 2009, 21:21
Hi to all.

I'm new on this forum. I try to find something like this but didn't find.

I need to develop excel-like spreadsheet with possibilities:
1. Data must be tree like:
Group
Element 1
Sub Element 1
......
Element 2
.......

And have possibility to expand and collapse each sublevels(+/- like in a tree)
2. Need to have a possibility to hide row like in excel. In fact, give height = 0 pixels and possibility to expand it by placing mouse between rows and drag down.

Some other functionality that I think don't have a influence for this.

For first one is good to use QTreeView, for second QTableView.

I start to using QTreeView. Can you help me, how to extend QTreeView for such functionality? :confused:

Zuzzu
13th September 2009, 22:34
Hi,

I think that you don't have to extend the QTreeView class because it is already providing all you need.

On the QTreeView you can set the related delegates objects for the display (I can name "custom display") and editing the data.

In order to implement the "Excel" editing, you have to implement a custom Model that will be the storage and manager for your specific data.

It is not a so hard work, you have just to understand the correct way to implement the Model for your specific requirements. I have already constructed an editor based on the QTreeView that is able to manage a lot of kind of data. The configuration of my "editor" is based on a SQL storage with the mapping of database column to the grid column (or a subset of grid colum) with also the management of different unit of measures for the different data type. The Delegate for the editing are also created and assigned in automatically (by the class derived from the QTreeView).

Bye

Alessandro

Stapl
14th September 2009, 18:04
Hi,

I think that you don't have to extend the QTreeView class because it is already providing all you need.

On the QTreeView you can set the related delegates objects for the display (I can name "custom display") and editing the data.

In order to implement the "Excel" editing, you have to implement a custom Model that will be the storage and manager for your specific data.

It is not a so hard work, you have just to understand the correct way to implement the Model for your specific requirements. I have already constructed an editor based on the QTreeView that is able to manage a lot of kind of data. The configuration of my "editor" is based on a SQL storage with the mapping of database column to the grid column (or a subset of grid colum) with also the management of different unit of measures for the different data type. The Delegate for the editing are also created and assigned in automatically (by the class derived from the QTreeView).

Bye

Alessandro

Thanks for your reply. I have my own model. But problem that I can't give to user a possibility to change row height in QTreeView. I investigate in row delegate and I think it don't give me needed functionality. It uses for data editing in row, custom row painting by cells....

Zuzzu
18th September 2009, 10:13
Thanks for your reply. I have my own model. But problem that I can't give to user a possibility to change row height in QTreeView. I investigate in row delegate and I think it don't give me needed functionality. It uses for data editing in row, custom row painting by cells....

Have you tried with Qt::SizeHintRole ??