Results 1 to 6 of 6

Thread: How to draw background for editor widget created by QStyledItemDelegate

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to draw background for editor widget created by QStyledItemDelegate

    Hello

    I've got following question:
    I have a view displaying some progress through a custom delegate subclassed from QStyledItemDelegate. I create a QSlider to edit the progress.

    The problem is, that each editor widget has to draw its own background, and has to overdraw the old one. So I set the setAutofill property of the slider to true, and get the result showed in the screenshot (background is one solid colour, but I want it to match the rest of the row).

    If I don't set the autofill property the background is not drawn at all, and I can see the progressbar drawn under the slider.

    I tried to intercept paint events to the slider and draw the background myself using QStyle()::drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter ), but this doesn't result in good results because I do not have the correct QStyleOptionViewItemV4 object (selection state etc. is not correct, because this is usually set by the view IMHO).

    So how can I draw the correct background for the slider without having to filter tons of events to find out the correct state of the item.

    Thanks in advance,
    Thomas
    Attached Images Attached Images

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.