Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有谁知道你如何“刷新”QT 中的列名(列标题)?
我的代码在某些情况下会更改列的名称。
model_ptr->header_list.replace( 1, "Bank #" );
另一个例子:
model_ptr->header_list.replace( 1, "Credit Union #" );
但是,只有当我实际单击列标题以按该列排序时,才会刷新。我希望它无需单击列标题即可更新。
使用模型的
void setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole)
方法应该导致视图更新。假设您的视图标题已连接到模型的headerDataChanged()信号。
headerDataChanged()