How to change qtableview data display font?
Printable View
How to change qtableview data display font?
Use QWidget::setFont() or make your model return the desired font for Qt::FontRole.
What about the other solution?
I have no idea how to achieve that ... :confused:
You said you have QTableView so you have a model too, right? QAbstractItemModel::data() returns data for various roles. Qt::FontRole is one of them.
I have:
- class, subclassed from QTableView (my view)
- class, subclassed from QStandardItemModel (my model)
- class, subclassed from QItemDelegate (my delegate)
How do I get to this font role?
Code:
{ if (index.isValid() && role == Qt::FontRole) }
Well, this is my code for data() function:Code:
{ if(index.isValid() && role==Qt::EditRole) return m_pMerchandizeOrder->orders()->at(index.row()).strDisplayString; //QStandardItemModel::data(index, role); if(index.isValid() && role==Qt::FontRole) }
And the result is still the same, the cell size is not updated. What is still missing?