I tried a proxyModel like this :
proxy->setModel(mySqlTableModel);
proxy->setHeaderData(0, Qt::Vertical, "test", Qt::DisplayRole);
QProxyModel *proxy = new QProxyModel;
proxy->setModel(mySqlTableModel);
proxy->setHeaderData(0, Qt::Vertical, "test", Qt::DisplayRole);
To copy to clipboard, switch view to plain text mode
second I added this code to SqlTableModel (subclass of QSqlTableModel).
bool SqlTableModel::setHeaderData(int section, Qt::Orientation orientation,
{
emit headerDataChanged(orientation, section, section);
return true;
}
else
{
return false;
}
}
bool SqlTableModel::setHeaderData(int section, Qt::Orientation orientation,
const QVariant & value, int role)
{
if(QAbstractItemModel::setHeaderData(section, orientation, value, role)){
emit headerDataChanged(orientation, section, section);
return true;
}
else
{
return false;
}
}
To copy to clipboard, switch view to plain text mode
mySqlTableModel->setHeaderData(1, Qt::Vertical, "Summe", Qt::DisplayRole);
mySqlTableModel->setHeaderData(1, Qt::Vertical, "Summe", Qt::DisplayRole);
To copy to clipboard, switch view to plain text mode
returns false
Bookmarks