Results 1 to 2 of 2

Thread: PyQt Filling in Table View cells

  1. #1
    Join Date
    Aug 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question PyQt Filling in Table View cells

    I'm struggling with filling in the cells of a Table View using a QStyledItemDelegate. I cannot figure out how to get the position of each cell so that I can fill certain cells with a color. I have attached a screenshot if that helps. Sorry if I am vague feel free to shoot me questions so I can clarify.
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: PyQt Filling in Table View cells

    Each cell is accessed via row/column information wrapped in a QModelIndex from the model that holds the data.
    The model can easily provide background color information which should then be used by the delegate already.

    If you need more than one color per cell, then you can still have the model provide the additional colors via custom roles and then use these roles in your delegate to query the colors using the QModelIndex's data() function.

    If you must decide the color in the delegate for some reason, then look at the row/column information of the QModelIndex.

    Cheers,
    _

Similar Threads

  1. Replies: 4
    Last Post: 7th August 2015, 08:45
  2. Replies: 7
    Last Post: 24th May 2011, 04:36
  3. Replies: 5
    Last Post: 3rd April 2010, 04:07
  4. Filling empty cells in QTableWidget
    By lyucs in forum Newbie
    Replies: 2
    Last Post: 20th October 2009, 17:12
  5. table with combobox cells
    By mgurbuz in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2006, 12:12

Tags for this Thread

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.