سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top