From 14a68137a7a1386d93819fab17ee6c228811731a 2017-06-29 07:35:01 From: Alexandre Leroux Date: 2017-06-29 07:35:01 Subject: [PATCH] Updates headerData() method to return column width/size for role Qt::SizeHintRole --- diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index 9e43407..e92a27a 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -4,6 +4,7 @@ #include #include +#include Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel") @@ -132,7 +133,7 @@ QVariant VariableModel::data(const QModelIndex &index, int role) const QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role != Qt::DisplayRole) { + if (role != Qt::DisplayRole && role != Qt::SizeHintRole) { return QVariant{}; } @@ -140,7 +141,9 @@ QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int auto propertiesIt = COLUMN_PROPERTIES.find(section); if (propertiesIt != COLUMN_PROPERTIES.cend()) { // Role is either DisplayRole or SizeHintRole - return QVariant{propertiesIt->m_Name}; + return (role == Qt::DisplayRole) + ? QVariant{propertiesIt->m_Name} + : QVariant{QSize{propertiesIt->m_Width, propertiesIt->m_Height}}; } else { qWarning(LOG_VariableModel())