Home > Software engineering >  QT QSqlTableModel tableview couldn't form according to the data
QT QSqlTableModel tableview couldn't form according to the data

Time:11-09


The model=new QSqlTableModel (this);
The model - & gt; SetTable (" good ");
The model - & gt; SetEditStrategy (QSqlTableModel: : OnManualSubmit);
The model - & gt; SetHeaderData (0, Qt: : Horizontal, tr (" product id "));
The model - & gt; SetHeaderData (1, Qt: : Horizontal, tr (" name of commodity "));
The model - & gt; SetHeaderData (2, Qt: : Horizontal, tr (" price "));
The model - & gt; SetHeaderData (3, Qt: : Horizontal, tr (" discount "));
The model - & gt; SetHeaderData (4, Qt: : Horizontal, tr (" inventory "));
The model - & gt; The select ();//select the entire table all lines
The UI - & gt; Goodtable - & gt; SetModel (model);
The UI - & gt; Goodtable - & gt; The horizontalHeader () - & gt; SetSectionResizeMode (QHeaderView: : Stretch);
Can see read three data and add data commits database is normal, is to show not to come out,
  • Related