Hi guys,

I have come across a problem the is to hard, sofar for me. Have an application with several dialogs, and one is a dialog built up with a combobox and a tableview + buttons

I have a
Qt Code:
  1. struct limits { float lower[10], float upper [10}]
To copy to clipboard, switch view to plain text mode 
that is written, based on 10 elements and 20 streams to a data file every 3 -5 minutes together with other data in my system.
The Filehandler is pointing to next position to write and when reaching the max values, return to the beginning of the file to continue. It holds 10 000 rows of data.

Now I want to present major data and limits based on a selected value in a combobox. That is, I create a QStandardItemModel models [ NoOfStreams ] and fills each Model with QStandardItem to be presented in a specific column and row.

Sofar so good, but when I select a stream and want to fetch the QStandardItemModel for the selected stream, either it doesn't show anything or it chrashes, depending och solution. The swaping is done in the View and the Models were created in the Models area and sent to the View's Q_Property.

So my question is How shall I perform the swapping, or am I doing (thinking) this wrong?

My ideas are from example FrozenColumn and modified
Qt Code:
  1. in Model
  2. read(filehandler, container, sizeOfLimits)
  3.  
  4. QStandardItemModel models[streams]
  5. //loop and fill with QStandardItem
  6. QStandardItem * newItem
  7. //for each stream,
  8. // for each row,
  9. // for each col
  10. newItem = new QStandardItem
  11. newItem->setText(container[col]->textValue)
  12. models[stream].setItem(row, col, newItem)
  13. //
  14. // asign models[] to VIEW ui's Q_PROPERTY
  15. gui->ui->setModel(models)
  16.  
  17. // VIEW
  18. // sofar OK
  19. // when comboBox index changed
  20. // verify in scope
  21. // this crasches
  22. tableview->setModel(Models()[cboBox_Index])
  23.  
  24. // but not this, and it displays nothing in the tableview
  25. QStandardItemModel *model = new QStandardItemModel(&m_Model[cboBox_index])
  26. tableview->setModel(model)
To copy to clipboard, switch view to plain text mode