Results 1 to 3 of 3

Thread: QTable with expandable cells

  1. #1
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTable with expandable cells

    Hi,

    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
    We can't solve problems by using the same kind of thinking we used when we created them

  2. #2
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTable with expandable cells

    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):
    Qt Code:
    1. if (role == Qt::DisplayRole)
    2. return vector.mean();
    3. if(| role == Qt::EditRole)
    4. QString values;
    5. for(int i=0;i<vector.size();i++)
    6. values+=QString::number(vector[i],...)+",";
    7. return values;
    To copy to clipboard, switch view to plain text mode 

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

  3. #3
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTable with expandable cells

    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
    We can't solve problems by using the same kind of thinking we used when we created them

Similar Threads

  1. QTable:: Cell's character limit
    By soumyadeep_pan in forum Qt Programming
    Replies: 0
    Last Post: 23rd October 2008, 05:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.