QSortFilterProxyModel got index out of range error when setting header data
I call setSourceModel() at widget constructor, at this point header data in source model as a QStringList is empty. Later when I call setHeaderData() to set header data based on the info I got from network, I get error message saying that QVector index out of range. it's from QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged().
Anybody knows why? All qt examples online doesn't cover this case.
more info about my problem: in my setHeaderData() function, I have "emit headerDataChanged(Qt::Horizontal, section, section);", this signal triggered slot QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged().
But based on QAbstractItemModel Class Reference, "When reimplementing function setHeaderData(), the headerDataChanged() signal must be emitted explicitly." so seems there is nothing wrong with my code.