Qtableview is quite complicated.
Qtableview is a view that displays the table format.
Table = new qtableview; its frequently used functions include:
1. display the grid table-> setshowgrid (false );
2. Adjust the column table by content-> resizecolumnstocontents ();
3. Get the vertical header table-> verticalheader (); of course, there is a horizontal header.
4. Set the non-editing status vtable-> setedittriggers (qtableview: noedittriggers); 5. Set the selection method and select the row verticalview-> setselectionbehavior (qtableview: selectrows );
6. model object
Qstandarditemmodel
* Model = newqstandarditemmodel;
model->setColumnCount(4);
model->setHeaderData(0,Qt::Horizontal,tr("File"));
model->setHeaderData(1,Qt::Horizontal,tr("Path"));
model->setHeaderData(2,Qt::Horizontal,tr("Size"));
model->setHeaderData(3,Qt::Horizontal,tr("Duration"));
Set the display model to 4 columns
7. Add item to model qstandarditem * Item1 =
New qstandarditem (TR ("yesterdayonce
More. Mid "));
QStandardItem* item2 = new QStandardItem(tr("C://Mid//"));
QStandardItem* item3 = new QStandardItem(tr("0.001M"));
QStandardItem* item4 = new QStandardItem(tr("3:48"));
QList<QStandardItem*> item;
item << item1 << item2 << item3 << item4;
Model-> appendrow (item); 8. Set the model to viewsetmodel (model );