QString fieldName; for(int i = 0; i < model()->columnCount(); i++) { fieldName = getFieldNameByIndex(i); model()->setHeaderData(i, Qt::Horizontal, setting->value("Column" + QVariant(i).toString() + "Name", fieldName).toString()); setColumnHidden(i, setting->value("Column" + QVariant(i).toString() + "Hidden").toBool()); }
model()->setData(index, myFont, Qt::FontRole); model()->setData(index, QColor(Qt::green), Qt::TextColorRole);
struct CellView{ QFont font; QColor fontColor; QColor backgroundColor; Qt::AlignmentFlag aligment;};
CellView s; for(int i = 0; i < model()->columnCount(); i++) { fieldName = getFieldNameByIndex(i); s.font = qvariant_cast<QFont>(setting->value("Column" + QVariant(i).toString() + "Font", fieldName)); s.fontColor = qvariant_cast<QColor>(setting->value("Column" + QVariant(i).toString() + "Color", fieldName)); s.backgroundColor = qvariant_cast<QColor>(setting->value("Column" + QVariant(i).toString() + "BackColor", fieldName)); s.aligment = Qt::AlignmentFlag(setting->value("Column" + QVariant(i).toString() + "Aligment", fieldName).toInt()); m_cellView->replace(i, s); }}