PDA

View Full Version : Hierarchical Table/Listview



cia.michele
2nd December 2009, 09:59
Goodmorning to all,
I'm a newbie of qt programming with a long experience in VB6 programming. Now, I'd like to convert my knowledge to Qt to create multiplatform software.
I've started to learn c++ and i made some small software in QT; now I'd like start the porting of a complete vb6 software to Qt. The first problem on this is the sequent: the original vb6 software use a hierarchical listview control to show two level of data (such as Invoice data and invoice details). This is a merge from treeWidget and TableWidget (or ListviewWidget).
Collapsed, it shows only the invoice data list, then clicking on one row, it shows an other listview (with different columns, in term of type and number) that contains the invoce details.
I've also see the example on the "C++ GUI Programming with Qt4, 2nd Edition" relative to the QRelationalSQLModel, but in that case, the example uses two control. I need to fuse those two control to one hierarchical control.
I looked for any information but I found nothing of useful (or enought clear and simple for me).
Could you help me? Have you got any ideas about this?

Thanks in advance for your answers.

Michele

squidge
2nd December 2009, 10:10
I think I get what you mean, and you'll need to subclass the closest component to provide the functionality you want.

Could you post a screenshot or two to reinforce what your after however? Pictures are far easier to parse than text :)

(You might even be able to do it using a data model and view)

cia.michele
3rd December 2009, 09:19
This are two picture that I hope could you understand better what I need. Sorry for confusing description, probably my english isn't perfect too. I try to explain again.
As you see in tables.png picutre, I've two tables; one of these contain a foreign key for the primary key of the other one. Now, I'd obtain the view in hierarchical_listview.png: filling the view with hierarchical data, selecting one row, i can display the dependent data directly from the view, opening another view (with different columns for number and type) to show the "details data". The classical example is Invoice (for the "master" table) and Invoice detail (for the "slave" table).
If you have any ideas about this, could you send me any example? As I sayd, I'm not as expert in QT as in vb6 :)

Thanks in advance for your help.

Michele

wysota
3rd December 2009, 10:02
Can't you just use a tree view? It seems it would do what you want just without that hideous look of tables extending past the end of the parent tree.

cia.michele
3rd December 2009, 10:44
Mmm peraphs it could be a solution, but, the treeview give the same columns for parent and child items isn'it? Or I can change? Otherwise, is it possible create a Listview (or table view) as treeviewItem? I looked for something about this, but I didn't find something useful.

Could you show me an example of your idea?

Thanks in advance for your help.

Michele

wysota
3rd December 2009, 11:30
Mmm peraphs it could be a solution, but, the treeview give the same columns for parent and child items isn'it?
Yes, so?


Or I can change?
No.


Otherwise, is it possible create a Listview (or table view) as treeviewItem?
Not really.

cia.michele
5th December 2009, 14:15
[QUOTE=wysota;124934]Yes, so?
So I need obtain the view in herarchical_table.png, with de slave item grouped in an inner table with different columns.

How can obtain this?

Thanks for your help

wysota
5th December 2009, 14:24
The same way you would do this with SQL. The most obvious way is to make a join of both tables. You can also set two headers for the table - one for each table.

cia.michele
7th December 2009, 09:50
Ok I know how make a join between the two tables, and I can learn how to set-up the QSqlRelationalModel (it is the most correct in this case isn't it?), but, who i set two headers to the same table? and then, I could select the row from both of different level? Could you show me a small examples?

Thanks for your time.

Michele