[Qt-interest] applying Tree model to Table view or convert Tree model to Table model

Valeriy Portnyagin portnyagin at reksoft.ru
Tue Jun 22 09:46:28 CEST 2010


Hello all,
i have next task:
 1. exists data structure like XML file. Fields contain: 
        plain text;
        special text(the text has special properties, like "status" for 
example);
        data;
        text properties and etc.

 2. create one data model like Tree(from XML file) contains all data.
like this:
        "1. chapter One
                plain text
                special text 1
                        property 11
                        property 12
                        property 13
                plain text
                1.2. chapter oneTwo
                        special text 2
                                property 21
                                property 22
                                property 23
                        plain text
        2. chapter Two
                special text 3
                        property 31
                        property 32
                        property 33
        .............."

 3. populate data from this model to several other models like custom 
Tree, Table.
        3.1. for custom Tree displayed only fields with plain text ( 
without special text properties and etc) in hierarchical view. like 
following:
        "1. chapter One
                plain text
                special text
                plain text
                1.2. chapter oneTwo
                        special text
                        plain text
        2. chapter Two
                special text
        .............."
 
        3.2. for custom Table displayed all data in plain structure(each 
item in own row), but for special text properties add needed count of 
column for display them. like following:


special text property 1
special text property 2
special text property 3
1. chapter One



plain text



special text 1
property 11
property 12
property 13
plain text



1.2. chapter oneTwo



special text 2
property 21
property 22
property 23
plain text



2. chapter Two



special text 3
property 31
property 32
property 33

It was an introduction. :)

point 1 and 2 are done but in the point 3  i have some issues. My aim is 
to have one Tree Model which is partly applied for Tree View and special 
applied or converted for Table View. I am trying to solve these tasks 
using QStandardItemModel, QSortFilterProxyModel with QTreeView, 
QTableView.

1. I can't apply Tree model for Table view with right displaying all 
items. Only the root items are displayed in the Table view without their 
children. Items "chapter 1, chapter 2" will be visible in my example. If i 
need to see all items i have to change the parents for all items, but it 
is impossible(i didn't see such method in the class). How can i see all 
items in the Table view  if i use Tree model?

2. It is impossible to create such Table view as i drew with several 
additional columns from my general Tree model. I  can do it using 
QTableWidget but i am losing flexibility of model/view programming. My 
QTableWidget will be independent from my model. Is there a way to avoid 
it?

3. For displaying the part of general Tree model i have the class 
QSortFilterProxyModel. But i have to create huge and difficult regular 
expression for filtering several items. In my case i will create regular 
expression for filtering all special text properties. If i have 10 
properties my regexp will be huge or difficult  or impossible. am i right 
or it can be done more elegant? 

I will appreciate any advices.

regards,
Valery Portnyagin.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100622/e339767e/attachment.html 


More information about the Qt-interest-old mailing list