View Full Version : QTable with expandable cells

20th April 2006, 10:39

I need to Display a set of Parameters and thier value for an object. and there Params can be of any type i.e int, float, text, vector( Array of double|int )
Some Basic manipulation like apply a formula.. has to be done. I am using table to display the params and the value of Params in two Cols of the table.

But when it comes to the Vectors, I don't want to display the whole set of values, rather thier mean has to be displayed. But It must be possible to change the single item in the vector. So I thought of giving an expanding option to the Cell so that the Vector's values will appear in the cells below the Vector cell.

I need to display the values of the Similar Objects in a single table. Now the manipuilation of the vectors is a big mess . the code has grown out of control.

Do you guys have a cleaner approach. Like subclassing the QTableItem so that the Vector will be represented in the Cell and options for expansion and the rest ...

thanks in advance

20th April 2006, 12:04
Hi,I'm not sure I have well understood what you mean... If you use the model/view framework you can do what you want by modifing the data() function of you model.
Inside the data function you can do something like this (I write a pseudocode concerning the vectors only):

if (role == Qt::DisplayRole)
return vector.mean();
if(| role == Qt::EditRole)
QString values;
for(int i=0;i<vector.size();i++)
return values;

In this way you obtain the mean when you show the object and you obtain the singles values when you try to edit it.

20th April 2006, 12:42
Sorry, I did not mention that I am using Qt3

I am looking for clean approach to bring in an Expandable cell.
the cell will containa list of value and when it expands all the values in the cell has tobe
set in the cells below the expandable cell