“Refreshing” column header names in QT model
문제
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.
제휴하지 않습니다 StackOverflow