This problem is encountered in the project when the filter model is used ..
When updating the model,
When the filter model is deleted and the source model is not updated, setColumnWidth (int column, int width) is used.
Later, I tried not to use the new filter model again, And setColumnWidth was enough.
Does it take effect if the filter model and source model must be deleted and assigned with the same setColumnWidth.
To re-write data to the source model, you need to set hidden columns again. To clear the source model, use
Int rowCount = m_tableModel-> rowCount ();
Int columnCount = m_tableModel-> columnCount ();
For (int I = 0; I <rowCount; I ++)
{
For (int j = 0; j <columnCount; j ++)
{
QStandardItem * pItem = m_tableModel-> item (I, j );
If (pItem)
{
Delete pItem;
}
}
}
Update Data
..................
..................
..................
Reset hide
M_tableModel-> setColumnCount (13 );
M_filterModel-> setSourceModel (m_tableModel );
M_filterModel-> setDynamicSortFilter (true );
M_tableModel-> setHorizontalHeaderLabels (m_headerString );
M_pTableView-> setModel (m_filterModel );
M_strFilter = "01234 ";
M_filterModel-> setFilterRegExp (QRegExp (QString ("[% 1]"). arg (m_strFilter); // filter rules
M_pTableView-> setColumnHidden (12, true );