Well, here is the problem:
I construct a
QTableView
and use thesetModel(myModel)
method which bind the modelmyModel
tomyTableView
;At first, there's no data in
myModel
, I use thehideColumn(0)
to do the job, and it works well, while after I load data tomyModel
, the column that I've hidden just shows up.
Would anyone tell me how to hold the hidden state of a column when the model changes?
Any suggestion is appreciated.
OK, here is the code.
void ModelView::createModelAndView()
{
_TableModel = new TableModel(this);
_Table = new QTableView(this);
_Table->setModel(_TableModel);
_Table->hideColumn(0);
_Table->hideColumn(10);
}
Now the _TableModel
has no data.
Then follows this:
_TableModel->loadData();
The loadData()
method is used to get data and push data to the model. Right after this step the view(i.e. _Table
) changes.