“清爽” QT 模型中的列标题名称

发布于 2024-12-28 06:27:04 字数 285 浏览 5 评论 0原文

有谁知道如何“刷新”QT 中的列名称(列标题)?

我的代码在某些情况下会更改列的名称。

model_ptr->header_list.replace( 1, "Bank #" );

另一个例子:

model_ptr->header_list.replace( 1, "Credit Union #" );

但是,只有当我实际单击列标题以按该列排序时,才会刷新。我希望它无需单击列标题即可更新。

Does anyone know how you "refresh" the names of the columns (the column headers) in QT?

I have code that, in certain cases, changes the name of a column.

model_ptr->header_list.replace( 1, "Bank #" );

Another example:

model_ptr->header_list.replace( 1, "Credit Union #" );

However this is only being refreshed when I actually click on the column header to sort by that column. I would like it to update without having to click on the column header.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风夜微凉 2025-01-04 06:27:04

使用模型的

void setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole)

方法应该会导致视图更新。假设您的视图的标头连接到模型的 headerDataChanged() 信号。

Using the model's

void setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole)

method should cause the view to update. Assuming your view's header is connected to the model's headerDataChanged() signal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文