문제

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