I want to read measured data from a device. At first the device tells me what data I can read from it, then the user is able to select the data he wants to measure. He can set an intervall time for measuring and then start the process.



Qt Code:
  1. //"monitorwindow.h"
  2. QStringList AvailableData;
  3. QCheckBox *DataCheckbox[];
To copy to clipboard, switch view to plain text mode 

This is the first proto type of the list that will be created (because communication to the device isn't ready yet):

Qt Code:
  1. void MonitorWindow::on_CreateListButton_clicked(){
  2. QVBoxLayout* verticalLayout = new QVBoxLayout;
  3.  
  4. AvailableData.append("Temp1");
  5. AvailableData.append("Temp2");
  6. AvailableData.append("Temp3");
  7. AvailableData.append("Temp4");
  8.  
  9. QLabel* tempLabel[AvailableData.count()];
  10. QHBoxLayout* horizontalLayout[AvailableData.count()];
  11.  
  12. for (int i = 0; i< AvailableData.count(); i++){
  13. DataCheckbox[i] = new QCheckBox;
  14. tempLabel[i] = new QLabel;
  15. horizontalLayout[i] = new QHBoxLayout;
  16.  
  17. connect(DataCheckbox[i],SIGNAL(clicked()),SLOT(setTransducerFlags()));
  18. horizontalLayout[i]->addWidget(DataCheckbox[i]);
  19.  
  20. tempLabel[i]->setText(AvailableData.at(i));
  21. horizontalLayout[i]->addWidget(tempLabel[i]);
  22.  
  23. horizontalLayout[i]->setStretch(1,9);
  24. verticalLayout->addLayout(horizontalLayout[i]);
  25. }
  26. ui->groupBox->setLayout(verticalLayout);
  27. }
To copy to clipboard, switch view to plain text mode 

On the basis of this list I want to create a tableview that shows me the selected data in different columns while measuring. But I really have no idea of creating a tableview dynamically, I always worked on the base of a model (that already was created).

So step by step. How can I add a new column and set the columnheader text to AvailableData.at(i)?

Thank You!