Results 1 to 2 of 2

Thread: how to change the palette while painting in QStyledItemDelegate

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    2
    Qt products
    Platforms
    Unix/X11

    Question how to change the palette while painting in QStyledItemDelegate

    I am using QStyledItemDelgate to provide editing widgets and paint different widget stand-ins for different data types. IE, all the items in my data model can be considered a name/value pair, of different types. Thus I want items to always appear as a checkbox for a bool, a lineedit for a string, combobox for an enum, lineedit+file browser button for a file, etc.

    To do this I am using QStyle.drawComplexControl(), .drawControl(), and the passed in QPainter.drawText() as needed. Now I'd like to apply a color scheme to the painting as an indication of status for each individual item (my own custom status-- not simply an enable state, etc). I've tried passing in a QPalette via QStyle.polish() (both before and after calling drawComplexControl), but it doesn't seem to actually do anything. I don't see a way to pass a palette with the drawControl and drawComplexControl calls.

    What am I missing?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: how to change the palette while painting in QStyledItemDelegate

    You can use the option parameter. In the option parameter you can set a palette.

Similar Threads

  1. QStyledItemDelegate and QStyle::State_MouseOver
    By moti.lahiani in forum Qt Programming
    Replies: 0
    Last Post: 19th January 2011, 07:36
  2. QStyledItemDelegate : too small to see contents
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2010, 20:38
  3. QStyledItemDelegate and editor pointer
    By Nero in forum Qt Programming
    Replies: 10
    Last Post: 20th September 2010, 19:42
  4. Question about subclassing QStyledItemDelegate
    By dpimka in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2009, 18:09
  5. Setting Format in a QStyledItemDelegate
    By Airswoop1 in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2009, 23:01

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.