qtableview - create a table in Qt and fill it by the user -


i want create qt application containing table of 3 columns , n row, user choose number of row putting in edit button , table have 3 columns , number given user. fill element

i have search lot found how fill able sql data,

please having idea?

here did far, have fixed number of rows , columns not want, besides, want use either qtablewidget or qtavleviewitem

 int n;          n = ui->spinbox->value();     qstandarditemmodel *model = new qstandarditemmodel(n,3,this); //2 rows , 3 columns      model->sethorizontalheaderitem(0, new qstandarditem(qstring("x")));      model->sethorizontalheaderitem(1, new qstandarditem(qstring("y")));      model->sethorizontalheaderitem(2, new qstandarditem(qstring("z")));       ui->tableview->setmodel(model); 

you can go through elements in qtableview , things them:

for(int r=0; r<n_rows; r++) {     for(int c=0; c<n_cols; c++)     {         qmodelindex index = ui->tableview->model()->index(r,c, qmodelindex());          // qvariant index.data() returns         qdebug() << r << c << index.data().tostring();     } } 

regards.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -