Results 1 to 3 of 3

Thread: Clear contents of a QTableView cell before repainting

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Platforms
    Unix/X11

    Default Clear contents of a QTableView cell before repainting

    First of all, I'm using PyQt4 4.4.3, python 2.6.2, and Qt 4.5.

    I am trying to display pixmaps sortable by filename in a QTableView. If I try to pass a QVariant containing a pixmap from my custom model's data method and paint the pixmap in my custom delegate, the images show up perfectly, but sorting isn't possible.

    As such, I've decided to instead pass a QVariant containing the file location of the image from my custom model's data method and convert it into a pixmap in the delegate. While sorting now works perfectly, the image is displayed behind the image's location.

    I've tried painter.setCompositionMode(), painter.eraseRect(), painter.filRext(), painter.restore(), and painter.setFont() in CustomDelegate to no avail.

    Is there some way to either cover the filename with the pixmap, change the fon't of the filename to transparent so that only the pixmap is shown, or clear the contents of the cell before painting the pixmap?

    Below is my python code, but I know enough c++ that solutions given in c++ are acceptable. Thanks in advance.

    from CustomItemDelegate:
    Qt Code:
    1. ...
    2. class CardItemDelegate(QItemDelegate):
    3. def __init__(self, parent=None):
    4. QItemDelegate.__init__(self, parent)
    5.  
    6. def paint(self, painter, option, index):
    7. if index.column() == IMAGE:
    8. painter.drawPixmap(option.rect,
    9. QPixmap(index.model().data(index).toString()))
    10. QItemDelegate.paint(self, painter, option, index)
    To copy to clipboard, switch view to plain text mode 
    Last edited by aspidites; 21st April 2009 at 16:15. Reason: [Solved] updated contents

Similar Threads

  1. how to color a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 13
    Last Post: 9th September 2015, 10:08
  2. How to tell if QTableView cell is visible ?
    By steviekm3 in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2009, 10:04
  3. How to tell if cell in QTableView is visible ??
    By steviekm3 in forum Qt Programming
    Replies: 3
    Last Post: 27th February 2009, 17:57
  4. cell selection in QTableView
    By user in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2008, 01:01
  5. Copying contents of QTableView cell to clipboard
    By Conel in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2006, 15:50

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.