Void QTableView: setColumnWidth (int column, int width), hidden columns do not work

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.