estanisgeyer
11th September 2009, 15:10
Hi,
With the property showgrid can enable and disable the grid in a QTableView. How can I do to display a grid with only horizontal lines? Is it possible?
Thanks,
Marcelo E. Geyer
victor.fernandez
11th September 2009, 16:14
AFAIK, it's not possible but you can create a custom delegate where you paint it the way you want.
class CustomDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
CustomDelegate(QObject *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
};
void CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
// Paint the line
painter->save();
painter->setPen(QColor(0, 0, 0, 220));
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
painter->restore();
// Now paint the normal cell contents
this->QStyledItemDelegate::paint(painter, option, index);
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.