0

I have some data which are stored in a variable "myStorage" (a QVector).

I use a QAbstractTableModel to display these data in a QTableView : each entry in the QVector is a row in the table and each field in "myStruct" is a column.

Now I want to display more information, in a new column, without any modification to "myStruct" or to my model.

So I tried to make a new model class, derived from QAbstractProxyModel, which should add the new "virtual" column.

(For example, this column could be the average of 2 existing fields in "myStruct")

But I can't make it work : in the worst case, the program crash, in the best case, I have the right number of columns (one more than in the proxied model) and the right headers, but the data are shifted and the last column is empty.

Is there any minimal/simple example of a "add virtual column proxy model" working implementation ?

Should I use QIdentityProxyModel as a base class instead of QAbstractProxyModel ?

Thanks

Aurelien
  • 1,032
  • 2
  • 10
  • 24
  • 1
    If you're asking why your code doesn't work, it'd be prudent to include the code - otherwise your question is off-topic. If you're asking for an off-site code example, that is off-topic too. If you're asking for such examples on this site, then all you have to do is use site search for the relevant classes. – Kuba hasn't forgotten Monica Dec 27 '16 at 23:02
  • Also you don't put spaces before question marks. – dtech Dec 28 '16 at 03:12
  • Take a look at [this](http://stackoverflow.com/questions/40987240/specializing-a-qabstractproxymodel-for-adding-a-column-the-table-cells-becomes) question. – Dmitry Dec 28 '16 at 04:20

0 Answers0