PDA

View Full Version : How to draw raised panel around each list item



topoden
5th January 2011, 02:12
Guys,

I was trying to understand how to properly reimplement paint method for QStyledItemDelegate so it draws each list item on a panels (like QFrame with frameShape=Panel and frameShadow=Raised).

I understand I need to use QStyle::drawPrimitive to do that, but here are my questions:

how to find proper primitive if I know the widget type the primitive should look like?
how do I find correct QStyledOption class for that and how can I understand what options to set in there?
if in addition to the raised panel I want to draw two iconed buttons on the right of the item, how do I make them behave as buttons actually?


What I finally what to achieve is something like this, I have a list of small selectable panels with a text on the center, check box on the right and two buttons on the left. If a check box on an item is not checked then the whole item is displayed semi-transparent, it should be displayed opaque otherwise. If user hits left button, the item should be moved one position up. If user hits right button, the item should be moved one position down (Or if its not very difficult, I would go even for drag-&-dropping them in the list)

How do I do that, and where do I read on how to properly reimplement QStyledItemDelegate::paint. I tried to find it in the assistance but apart from a very easy example with stars (which does not help at all) I could not find any explanations.

Thank you in advance!

Added after 1 8 minutes:

As an extra question: would it be better / more correct to implement what I want as a list of real widgets in a vertical layout?

Even if this is better I still hope to get the answers on the questions above, as I still don't understand how to I implement paint method using the style and options. The general idea is clear but the detail are always the evil (good explanation link would be very helpful, as I still can not find any good info on this in the assistant. Everywhere only highveiw stuff is written and said that I need to go to another class documentation for more details, but if I go there I dont get anything new apart from the next promise to see the details in a next class documentation...)