Qtableview draw border
Unsolved
General and Desktop
-
Use a custom item delegate and override the paint() to draw a border around the cell.
-
ok something like this
void CustomDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { QStyledItemDelegate::paint(painter, option, index); QPen oldPen = painter->pen(); painter->setPen(_gridPen); // paint vertical lines painter->drawLine(option.rect.topRight(), option.rect.bottomRight()); // paint horizontal lines if (index.column()!=1) //<-- check if column need horizontal grid lines painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); painter->setPen(oldPen); }
And in qtableview row how can i set font for a particular row
as for table i can use ui.tableView->setFont(QFont("Times", 10));
but only for row how to do ? -
@n-2204 said in Qtableview draw border:
And in qtableview row how can i set font for a particular row
Similar to your painting. Don't forget to override https://doc.qt.io/qt-5/qstyleditemdelegate.html#sizeHint