[Qt-interest] How Insert itens in QTableView ?

Chris W qtinterest at psychogeeks.com
Sat Sep 12 03:10:40 CEST 2009


Mhayk Whandson wrote:
> My doubt is
> how can I insert the values in the model ? Could you show me an
> example ?

You probably want to look at these in QAbstractItemModel:

bool insertRow(int row, const QModelIndex & parent = QModelIndex() )

virtual bool setData ( const QModelIndex & index, const QVariant &
value, int role = Qt::EditRole )

QModelIndex index ( int row, int column, const QModelIndex & parent =
QModelIndex() )

Use insertRow() with row == model.rowCount() to create a new row at the
end of the table, or another row number to insert elsewhere.  Use
setData() to put your values into columns using indexes obtained with
index().

Read the docs under Overviews-Model/View Programming and the associated
examples.



More information about the Qt-interest-old mailing list