int TradeTableModel::columnCount ( const QModelIndex & parent/* = QModelIndex() */) const
{
return COLUMN_TOTAL;
}
这个方法的作用是,返回model中的列的数量。
最终目的是:限制了model中headerData()的调用次数。
columnCount()方法的调用时机:
在view调用了setModel()方法后,
首先调用columnCount()方法,获取到model中的列的数量。
然后调用headerData()方法,获取model中各个列的名字。如果columnCount()返回的是10.
那么headerData()方法的调用次数就是10次。
这就是model中columnCount()方法的最终作用。