Results 1 to 4 of 4

Thread: Wrong painting of Delegate

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Wrong painting of Delegate

    Hi, all, i sub class QStyledItemDelegate and re-implement the paint () function like this:
    Qt Code:
    1. void CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const
    2. {
    3. painter->save();
    4. painter->fillRect(option.rect, QBrush(Qt::red));
    5. painter->setPen(QColor(Qt::black));
    6. painter->drawRect(option.rect);
    7. painter->restore();
    8. QStyledItemDelegate::paint(painter, option, text, false);
    9. }
    To copy to clipboard, switch view to plain text mode 

    Sadly the delegate paint the item beyond the boder of the QListView and looks like the attachment. I don't know why. The picture in the attachment is a screen shotcut when the cursor hover the area that is very near to the list veiw's bottom border, outside the view.

    Any help and suggestions will be appreciated greatly, thank you in advance.
    Attached Images Attached Images

Similar Threads

  1. Painting a CC_ToolButton in a custom delegate
    By victor.fernandez in forum Qt Programming
    Replies: 2
    Last Post: 17th October 2008, 12:11
  2. Delegate for a certain item?
    By somebody in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2008, 22:55
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37

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
  •  
Qt is a trademark of The Qt Company.