Results 1 to 2 of 2

Thread: Grid QTableView horizontal only

  1. #1
    Join Date
    Jan 2008
    Location
    Brasil
    Posts
    131
    Thanks
    18
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Grid QTableView horizontal only

    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

  2. #2
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Grid QTableView horizontal only

    AFAIK, it's not possible but you can create a custom delegate where you paint it the way you want.

    Qt Code:
    1. class CustomDelegate : public QStyledItemDelegate
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CustomDelegate(QObject *parent = 0);
    7. void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
    8. };
    9.  
    10.  
    11. void CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
    12. {
    13. // Paint the line
    14. painter->save();
    15. painter->setPen(QColor(0, 0, 0, 220));
    16. painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
    17. painter->restore();
    18.  
    19. // Now paint the normal cell contents
    20. this->QStyledItemDelegate::paint(painter, option, index);
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by victor.fernandez; 11th September 2009 at 16:20.

Similar Threads

  1. Replies: 2
    Last Post: 7th June 2009, 10:47
  2. QTableView Horizontal Bar depressed, looks ugly.
    By killerwookie99 in forum Qt Programming
    Replies: 5
    Last Post: 4th March 2009, 14:01
  3. QTableView Horizontal Header's Width
    By araglin in forum Newbie
    Replies: 3
    Last Post: 21st December 2008, 08:54
  4. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 20:51
  5. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.