Results 1 to 4 of 4

Thread: 3 Different Color for in QTablewidgetItem

  1. #1
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 3 Different Color for in QTablewidgetItem

    Hi All,

    I want to add backgound of three different color to QTableWidgetItem. Is there any way to achieve this? Waiting for ur reply.


    Thanks
    Jnana

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 3 Different Color for in QTablewidgetItem

    Use setData with Qt::BackgroundColorRole role.

  3. #3
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: 3 Different Color for in QTablewidgetItem

    Hi wysota,

    Thanks for reply. But, I was not able to follow it.

    setData () takes two argument, one Qt::BackgroundRole, another a QVariant object. I don't know what should be the latter object. Is it possible by adding QBrush with QGrident as second argument will change the background color to gradient type color? If I am wrong can explain what u want to convey to me.

    Thanks
    Jnana

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 3 Different Color for in QTablewidgetItem

    Quote Originally Posted by jnana
    setData () takes two argument, one Qt::BackgroundRole, another a QVariant object. I don't know what should be the latter object.
    The value you want to set.

    Is it possible by adding QBrush with QGrident as second argument will change the background color to gradient type color?
    It is possible but as far as I remember the default delegate (QItemDelegate) doesn't handle gradients, so it'll probably not work. It's safest to put some QColor (you can add a pattern too) there. Play with it.

Similar Threads

  1. Focus of cells in a QTableWidget
    By SailinShoes in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2008, 08:19
  2. QTableWidgetItem not enabled
    By Raccoon29 in forum Newbie
    Replies: 2
    Last Post: 21st March 2008, 18:39
  3. Replies: 1
    Last Post: 21st August 2007, 16:25
  4. QTableWidgetItem and formatting / input masks
    By Walter in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2007, 13:39
  5. Interesting little Segfault w/r to signal/slot connection
    By Hydragyrum in forum Qt Programming
    Replies: 24
    Last Post: 12th September 2006, 19:22

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.